2014-02-19 53 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開始。