我不知道为什么会这样,下面是我的代码。我怀疑它与范围有关,但是我可以 var_dump $items 就好了。
<?php
/*
* Setup the API scripts.
*/
require (dirname(__FILE__).'/vesu/SDK/Gw2/Gw2SDK.php');
require (dirname(__FILE__) .'/vesu/SDK/Gw2/Gw2Exception.php');
use \vesu\SDK\Gw2\Gw2SDK;
use \vesu\SDK\Gw2\Gw2Exception;
// Request a new instance of the API
$gw2 = new Gw2SDK(dirname(__FILE__).'/cache/items/', 604800);
// End of code header
function refreshCache($gw2){
$i=0;
$items = $gw2->getItems();
#var_dump($items);
foreach($items as $itemId){
var_dump($itemsId);
$item = $gw2->queryItemDetails($itemId);
var_dump($item);
$itemName = $item->name;
echo "writing " . $itemId . "," . $itemName . "to the cache";
$i++;
}
echo "Added " . $i . " Items to the cache.";
}
refreshCache($gw2);
?>