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