Reputation: 1496
Finditemsadvanced call in Ebay webservices and in the SDK for PHP includes the possibility to getHistograms for categories.
FindingServices.php display the following code:
public function getHistograms(\DTS\eBaySDK\Finding\Types\GetHistogramsRequest $request)
{
return $this->callOperation(
'getHistograms',
$request,
'\DTS\eBaySDK\Finding\Types\GetHistogramsResponse'
);
}
public function findItemsAdvanced(\DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest $request)
{
return $this->callOperation(
'findItemsAdvanced',
$request,
'\DTS\eBaySDK\Finding\Types\FindItemsAdvancedResponse'
);
}
In my controller I try two version to call FindingItemsAdvanced including GetHistograms.
/** Create the service object.*/
$service = new DTS\eBaySDK\Finding\Services\FindingService(array(
'appId' => $config['production']['appId'],
'apiVersion' => $config['findingApiVersion'],
'globalId' => DTS\eBaySDK\Constants\GlobalIds::US
));
/** Create the request object.*/
$request = new DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest();
$request->keywords = 'ipod nano';
$request->categoryId = array('73839');/** Search across two categories. * DVDs & Movies > DVDs & Blue-ray (617) * Books > Fiction & Literature (171228)*/
$request->outputSelector = array('AspectHistogram','CategoryHistogram','SellerInfo');
$itemFilter = new DTS\eBaySDK\Finding\Types\ItemFilter();/** Filter results to only include auction items or auctions with buy it now. */
$itemFilter->name = 'ListingType';
$itemFilter->value[] = 'FixedPrice';
$itemFilter->value[] = 'AuctionWithBIN';
$request->itemFilter[] = $itemFilter;
/** Get Histograms */
check below option 1 and option 2 and its errors
/** response */
$response = $service->findItemsAdvanced($request);
using option 1:
$request->getHistograms = new DTS\eBaySDK\Finding\Types\GetHistogramsRequest();
$request->getHistograms = (array('73839'));
but its giving me the following error: Unknown property: DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest::getHistograms
using option 2:
$request1 = new DTS\eBaySDK\Finding\Types\GetHistogramsRequest();
$histograms = $service->getHistograms($request1);
$request->$histograms = (array('73839'));
but its giving me the following error: "Unknown property: DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest::Object"
I know that in the SDK getHistograms() is not part of FindItemsAdvanced() but its a part of FindingService.php consequently I assume it could be called in the same action. Any help or example code using finditems with histograms in same call appreciated.
Upvotes: 1
Views: 507
Reputation:
The category that you are using is Consumer Electronics > Portable Audio & Headphones > iPods & MP3 Players (73839). While this is a valid category ID, both getHistograms and findItemsAdvanced will not return a categoryHistogram element. The reason for this is explained in the documentation for getHistograms
This container is returned only when the specified category has children categories.
And also in the findItemsAdvanced documentation.
The category IDs returned for items in search results are for the leaf categories in which the items are listed. If you use these category IDs as input, the response will not return a category histogram.
In other words the categoryHistogram element will not be returned by either service if a leaf category is specified in the request. A leaf category is just a category that has no children. Since the category 73839 is a leaf category you will instead have to use its parent Consumer Electronics > Portable Audio & Headphones (15052).
The links below should return the categoryHistogram. You just need to replace <YOUR APP ID>
in the URL.
http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=<YOUR APP ID>&OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.13.0&GLOBAL-ID=EBAY-US&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&categoryId(0)=15052&outputSelector(0)=AspectHistogram&outputSelector(1)=CategoryHistogram&outputSelector(2)=SellerInfo
http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=<YOUR APP ID>&OPERATION-NAME=getHistograms&SERVICE-VERSION=1.13.0&GLOBAL-ID=EBAY-US&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&categoryId(0)=15052
Upvotes: 3