eBay API GetSearchResults call returns 'Undefined property: SoapFault::$SearchResultItemArray' error

StackOverflow https://stackoverflow.com/questions/21879451

  •  13-10-2022
  •  | 
  •  

Question

I have a project where i need to access a product list from EBay based on a keyword search, i am familiar with apis so i am just trying to get my head around ebays.

Ok so far i started by signing up for a Ebay developer login all done have all my ID's keys etc.

Headed over to https://go.developer.ebay.com/developers/eBay/documentation-tools/code-sample/219177 and downloaded the PHP code sample as this is the one i am going to be using.

Ok so entered all my details and the call i want to run is GetSearchResults.

Everytime i run this command i get the error below.

Undefined property: SoapFault::$SearchResultItemArray

Can any help me with this or can they point me in the right direction of a working php sdk that i can use to get a display of search results?

Here is the code taken from ebay developer 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";
?>

Thanks

Was it helpful?

Solution

I was having a similar issue and I found this:

Important: GetSearchResults and GetCategoryListings are now deprecated and are no longer available. If you have applications that use the calls, please migrate your search functions to the Finding API. For new applications, please start with the Finding API.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top