Is it possible to get the eBay Category List via an API programmatically?

不羁的心 提交于 2020-01-01 15:05:17

问题


My goal is to get a list of eBay categories programmatically.

It appears that the GetCategories method is only available from the Trading API. If I understand correctly, there is user interaction required to log into the Trading API: http://developer.ebay.com/DevZone/XML/docs/HowTo/Tokens/GettingTokens.html

Is there another method to get the eBay categories list programmatically?

I'm using Drupal 7, so PHP.


回答1:


You do not need a token to get the categories. All you need is your App-ID

The link below with your APP-ID will return the XML category listing from site: UK (siteid=3) Setting CategoryID=-1 starts the list at the root level, you can start from any category, just use IncludeSelector=ChildCategories to get children

http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=YOUR-APP-ID&siteid=3&CategoryID=-1&version=729&IncludeSelector=ChildCategories

Now just use SimpleXML or whatever to parse.




回答2:


This may have been correct at the time, however this call in the API now only returns you one level of categories, not the entire hierarchy. To do it for a whole site, in one request (which can get quite large) you need to use the GetCategories call with a valid Ebay token, and specify <DetailLevel>ReturnAll</DetailLevel> and <ViewAllNodes>true</ViewAllNodes>.

Also note you will need to update these regularly and provide a mapping algorithm as Ebay expires and remaps categories to new names / ids over time.




回答3:


You can use the following url to get the top level category list. Once you get the list of the categories, you can check if [LeafCategory] is true or false. If it is true for the category, you can again fetch the sub-category by specifying the categoryParentId. You can use the php Curl to get the results and then you can use simple_xml_object to fetch the returned xml response $url= 'http://open.api.ebay.com/Shopping?callname=GetCategoryInfo&appid=YOUR-APP-ID&siteid=3&CategoryID=-1&version=729&IncludeSelector=ChildCategories'; $sXML = download_page($url); $oXML = simplexml_load_string($sXML); print_r($oXML);exit; function download_page($path){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$path); curl_setopt($ch, CURLOPT_FAILONERROR,1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); $retValue = curl_exec($ch); curl_close($ch); return $retValue; }



来源:https://stackoverflow.com/questions/8114617/is-it-possible-to-get-the-ebay-category-list-via-an-api-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!