2015-09-28 47 views
1

Finditemsadvanced在Ebay网络服务和SDK for PHP中的呼叫包括获取类别的可能性。Ebay FindItemsAdvanced呼叫包括GetHistograms

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。使用选项1

/** 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); 

$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与直方图在相同的电话赞赏。

回答

3

您正在使用的类别是消费电子>便携式音响&耳机> iPods & MP3播放器(73839)。虽然这是一个有效的类别ID,但getHistograms和findItemsAdvanced都不会返回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元素。叶子类别只是一个没有孩子的类别。由于类别73839是叶子类别,您将不得不使用其父类消费电子产品>便携式音频耳机(15052)。

下面的链接应该返回categoryHistogram。您只需在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 
+0

谢谢大卫,其明确与您的解释。最好的祝福! –