【问题标题】:eBay API GetSearchResults call returns 'Undefined property: SoapFault::$SearchResultItemArray' erroreBay API GetSearchResults 调用返回“未定义属性:SoapFault::$SearchResultItemArray”错误
【发布时间】:2014-02-19 11:42:57
【问题描述】:

我有一个项目,我需要根据关键字搜索从 eBay 访问产品列表,我熟悉 api,所以我只是想了解一下 ebays。

好的,到目前为止,我首先注册了一个 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";
?>

谢谢

【问题讨论】:

  • 你能给我们看一些代码吗?
  • 肯定会更新答案,它只是这里的确切代码go.developer.ebay.com/developers/eBay/documentation-tools/… expand view code on php example,但我也会在上面添加;)
  • 您很可能会看到此错误,因为对 GetSearchResults 的调用失败。取消注释//print_r($results); 行,并检查可能的错误消息。您确定您在ebay.ini 中正确输入了所有详细信息吗?通过转储$config 来验证这一点。
  • 嗨,克里斯,当我打印结果时,我收到此错误函数(“GetSearchResults”)不是此服务的有效方法,所以我有点困惑服务 api 调用是否发生了变化。配置似乎很好,服务 url 网关在那里api.sandbox.ebay.com/wsapi
  • @user1503606:出现该错误几乎可以肯定地意味着创建客户端 (new eBaySOAP($session);) 失败 - 这很可能是因为 $session 中的详细信息,因此 $config 中的详细信息不正确。跨度>

标签: php ebay-api


【解决方案1】:

我遇到了类似的问题,我发现了这个:

重要提示:GetSearchResults 和 GetCategoryListings 现已弃用且不再可用。如果您有使用这些调用的应用程序,请将您的搜索功能迁移到 Finding API。对于新应用程序,请从 Finding API 开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    • 1970-01-01
    相关资源
    最近更新 更多