我有一个项目,我需要根据关键字搜索从eBay访问产品列表,我熟悉apis所以我只是试图让我的头围绕ebays。
好的,到目前为止,我开始注册一个Ebay开发者登录,所有已经完成了我所有的ID密钥等。
前往https://go.developer.ebay.com/developers/eBay/documentation-tools/code-sample/219177并下载了PHP代码示例,因为这是我将使用的。
好的,所以输入了我的所有细节,我想要运行的电话是GetSearchResults。
每次我运行此命令时都会收到以下错误。
Undefined property: SoapFault::$SearchResultItemArray
有没有人可以帮我这个,还是他们可以指出我正在使用的php sdk的正确方向,我可以用它来显示搜索结果?
以下是从易趣开发者https://go.developer.ebay.com/developers/eBay/documentation-tools/code-sample/219177
中获取的代码<?php
// be sure include path contains current directory
// to make sure samples work
ini_set('include_path', ini_get('include_path') . ':.');
// Load general helper classes for eBay SOAP API
require_once 'eBaySOAP.php';
// Load developer-specific configuration data from ini file
$config = parse_ini_file('ebay.ini', true);
$site = $config['settings']['site'];
$compatibilityLevel = $config['settings']['compatibilityLevel'];
$dev = $config[$site]['devId'];
$app = $config[$site]['appId'];
$cert = $config[$site]['cert'];
$token = $config[$site]['authToken'];
$location = $config[$site]['gatewaySOAP'];
// Create and configure session
$session = new eBaySession($dev, $app, $cert);
$session->token = $token;
$session->site = 1; // 100 = eBay Motors
$session->location = $location;
// Make a series of GetSearchResults API calls and print results
try {
$client = new eBaySOAP($session);
// Find 10 ipods and print their Titles
$params = array('Version' => $compatibilityLevel,
'Query' => 'ipod',
'Pagination' => array('EntriesPerPage' => 10),
);
$results = $client->GetSearchResults($params);
print "<pre>";
//print_r($results);
print "</pre>";
foreach ($results->SearchResultItemArray as $item) {
echo $item, " <br>\n";
}
print "<p>---</p>\n";
// Find 10 passenger vehicles (CategoryID 6001) within 10 miles of ZIP Code 95125
// ordered by ascending distance
$params = array('Version' => $compatibilityLevel,
'Query' => '*',
'CategoryID' => 6001,
'ProximitySearch' => array('MaxDistance' => 10, 'PostalCode' => 95125),
'Pagination' => array('EntriesPerPage' => 10),
'Order' => 'SortByDistanceAsc',
);
$results = $client->GetSearchResults($params);
foreach ($results->SearchResultItemArray->SearchResultItem as $item) {
print $item->Item->Title . " <br> \n";
}
print "<p>---</p>\n";
// Find the count of all passenger vehicles (CategoryID 6001)
$params = array('Version' => $compatibilityLevel,
'Query' => '*',
'CategoryID' => 6001,
'TotalOnly' => true,
);
$results = $client->GetSearchResults($params);
$total = number_format($results->PaginationResult->TotalNumberOfEntries);
print "There are $total passenger vehicles for sale on eBay Motors <br>\n";
} catch (SOAPFault $f) {
print $f; // error handling
}
// Uncomment below to view SOAP envelopes
// print "Request: \n".$client->__getLastRequest() ."\n";
// print "Response: \n".$client->__getLastResponse()."\n";
?>
由于
答案 0 :(得分:1)
我遇到了类似的问题,我发现了这个问题:
重要说明:GetSearchResults和GetCategoryListings现已弃用,不再可用。如果您有使用这些调用的应用程序,请将搜索功能迁移到Finding API。对于新应用程序,请从Finding API开始。