0
我需要知道爲什麼此代碼調用易趣API GetCategoryInfo不會工作,先前類似以前檢索信息,但對於我的生活我似乎無法得到它的工作,錯誤是foreach,說警告:爲foreach()提供的無效參數可能是這行嗎?打電話GetCategories ebay API列出所有
「$ xml = new SimpleXMLElement($ resp);」該APPID被隱藏的原因很明顯,
$url = 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo';
$url .= '&appid=' . $appid . '&siteid=3&CategoryID=-1&version=729&IncludeSelector=ChildCategories';
$resp = file_get_contents($url);
$xml = new SimpleXMLElement($resp);
foreach($xml->searchResult->Item as $item)
{
$categoryName = (string) $item->primaryCategory->categoryName;
$catid = (string) $item->primaryCategory->CategoryID;
echo $categoryName . " " . $catid . " <br>\n";
}
變化,以反映工作片斷
foreach($xml->CategoryArray->Category as $category)
{
$categoryName = (string) $category->CategoryName;
$catid = (string) $category->CategoryID;
echo $categoryName . " " . $catid . " <br>\n";
}
大,感謝的是,現在的話,我想導入每個類別和子類別,您認爲最好的解決方案是什麼,或者這是一個單獨的線程? – smashit