question

improveyourlife avatar image
0 Likes"
improveyourlife asked ·

Help with getting getcategoryinfo list

Ned help listing all categories and child categories, ive looked at docs, cant seem to figure it out, this gives the error Warning: Invalid argument supplied for foreach() $url = ' http://open.api.ebay.com/Shopping?callname=GetCategoryInfo'; $url .= '≈pid=' . $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 . "
\n"; } ?>
api-problemgetcategories
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

davidtsadler avatar image
1 Like"
davidtsadler answered ·
If you're interested there is an [example of how to call GetCategoryInfo]( https://github.com/davidtsadler/ebay-sdk-examples/blob/master/shopping/03-get-category-info.php) using a [PHP SDK]( https://github.com/davidtsadler/ebay-sdk-php) that I've developed. There is also an example of getting the [categories via the Trading API]( https://github.com/davidtsadler/ebay-sdk-examples/blob/master/trading/02-get-category-hierarchy.php). [ 'appId' => 'your-app-id', 'certId' => 'your-cert-id', 'devId' => 'your-dev-id' ] ]); $request = new Types\GetCategoryInfoRequestType(); $request->CategoryID = '-1'; $request->IncludeSelector = 'ChildCategories'; $response = $service->getCategoryInfo($request); foreach ($response->CategoryArray->Category as $category) { printf( "Category (%s) %s\n", $category->CategoryID, $category->CategoryName ); }
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

improveyourlife avatar image
0 Likes"
improveyourlife answered ·
I'm revisiting this category list, can I alter the above to get parent and child categories for each mani category?
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

improveyourlife avatar image
0 Likes"
improveyourlife answered ·
In cpanel you can just export a taable, is this not possible with the categories table using an API call?
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

clickimusprime avatar image
0 Likes"
clickimusprime answered ·
**how can i add to this to show the full hierarchy of all categories and child cats so i can create sql insert statements to import all the folders?** You have to start at the top, read categories, then make additional calls to get the children of those categories. Before you go down this path, you might consider whether you really need to pull all the categories. Also notice that the CategoryIDPath and CategoryNamePath for a given category contains the parent hierarchy information for the category. Consumer Electronics:Vintage Electronics:Vintage Audio & Video:Reel-to-Reel Tape Recorders 293:183077:175740:116868 This information can be used directly for things like breadcrumbs without making additional calls or requiring a database. This information is also returned in the Shopping API GetSingle/MultipleItems responses so you can avoid using GetCategoryInfo at all if you can use this data instead. Alas, Finding still does not return this info. If it did, the Shopping or GetCategoryInfo calls could be skipped there too.
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

improveyourlife avatar image
0 Likes"
improveyourlife answered ·
Ok, thanks for input below is working snippet, how can i add to this to show the full hierarchy of all categories and child cats so i can create sql insert statements to import all the folders? foreach($xml->CategoryArray->Category as $category) { $categoryName = (string) $category->CategoryName; $catid = (string) $category->CategoryID; echo $categoryName . " " . $catid . "
\n"; }
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

improveyourlife avatar image
0 Likes"
improveyourlife answered ·
Could this be altered so it uses my url way? I notice you going into folders I don't have
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

davidtsadler avatar image
0 Likes"
davidtsadler answered ·
If you look at the [output]( https://developer.ebay.com/DevZone/shopping/docs/CallRef/GetCategoryInfo.html#Output) for GetCategoryInfo you can see that ``searchResult`` is not part of the result. You need to change your code to: > foreach($xml->CategoryArray->Category as $category)
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.