Ebay FindItemsAdvanced调用包括GetHistograms

时间:2015-09-28 00:14:40

标签: php xml sdk ebay ebay-api

Finditemsadvanced在Ebay网络服务中调用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的任何帮助或示例代码。

1 个答案:

答案 0 :(得分:3)

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

的文档中解释了这一点的原因
  

仅当指定的类别具有此容器时才返回此容器   儿童类别。

还有findItemsAdvanced文档。

  

为搜索结果中的项目返回的类别ID适用于叶子   列出项目的类别。如果您使用这些类别   ID作为输入,响应不会返回类别直方图。

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

以下链接应返回categoryHistogram。您只需要在网址中替换<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