2014-02-19 55 views
0

我有一个项目,我需要从eBay根据关键字搜索访问产品列表,我熟悉apis,所以我只是想让我的头在eBay附近。使用Ebay的PHP搜索产品

好到目前为止,我开始通过注册一个eBay的开发人员登录都做有我所有的ID钥匙等

领导交给https://go.developer.ebay.com/developers/eBay/documentation-tools/code-sample/219177和下载的PHP代码示例,因为这是一个我将是使用。

好的,所以我输入了所有的细节和我想要运行的调用GetSearchResults。

每次我运行这个命令我得到下面的错误。

Undefined property: SoapFault::$SearchResultItemArray 

任何能帮助我或者他们可以点我在工作PHP SDK,我可以用它来获取搜索结果的显示的方向是正确的?

下面是来自eBay开发者所采取的代码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

你能告诉我们一些代码吗? – Fabio

+0

肯定不适合更新答案它只是从这里确切的代码https://go.developer.ebay.com/developers/eBay/documentation-tools/code-sample/219177扩大在PHP示例的视图代码,但生病也添加上面; ) – user1503606

+0

很可能你看到这个错误,因为调用GetSearchResults失败。取消注释行// // print_r($ results);',并检查可能的错误消息。你确定你已经在'ebay.ini'中正确输入了所有的细节吗?验证也通过倾销'$ config'。 – Chris

回答

1

我有一个类似的问题,我发现这一点:

重要提示:现在GetSearchResults和GetCategoryListings正在过时,不再可用。如果您的应用程序使用这些呼叫,请将您的搜索功能迁移到Finding API。对于新的应用程序,请从Finding API开始。