Ebay FindItemsAdvanced 调用包括 GetHistograms

Ebay FindItemsAdvanced call including GetHistograms

Finditemsadvanced call in Ebay webservices and in the SDK for PHP 包括获取类别直方图的可能性。

FindingServices.php 显示以下代码:

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'
    );
}

在我的控制器中,我尝试了两个版本来调用 FindingItemsAdvanced,包括 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);

使用选项 1:

$request->getHistograms = new DTS\eBaySDK\Finding\Types\GetHistogramsRequest();
$request->getHistograms = (array('73839'));

但它给我以下错误:Unknown property: DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest::getHistograms

使用选项 2:

$request1 = new DTS\eBaySDK\Finding\Types\GetHistogramsRequest();
$histograms = $service->getHistograms($request1);
$request->$histograms = (array('73839'));

但它给我以下错误:"Unknown property: DTS\eBaySDK\Finding\Types\FindItemsAdvancedRequest::Object"

我知道在 SDK 中,getHistograms() 不是 FindItemsAdvanced() 的一部分,而是 FindingService.php 的一部分,因此我认为可以在同一操作中调用它。感谢在同一调用中使用带有直方图的 finditems 的任何帮助或示例代码。

您使用的类别是消费电子产品 > 便携式音频和耳机 > iPod 和 MP3 播放器 (73839)。虽然这是一个有效的类别 ID,但 getHistograms 和 findItemsAdvanced 都不会 return categoryHistogram 元素。 getHistograms

的文档中解释了这样做的原因

This container is returned only when the specified category has children categories.

并且也在 findItemsAdvanced 文档中。

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.

换句话说,如果在请求中指定了叶类别,则 categoryHistogram 元素将不会被任一服务 return 编辑。叶类别只是一个没有子类别的类别。由于类别 73839 是叶类别,因此您必须使用其父类别消费电子产品 > 便携式音频和耳机 (15052)。

下面的链接应该 return 类别直方图。您只需要替换 URL 中的 <YOUR APP ID>

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