skip to Main Content

Im trying to perform a simple call using ebays search API, when I make a call I get no response, and the problem is with the actual call itself.

$endpoint = 'http://open.api.ebay.com/shopping?';  
$responseEncoding = 'XML';   
$version = '631';   // API version number
$appID   = 'asdf3e6e3'; 
$itemType  = "AllItemTypes";
$itemSort  = "EndTime";

//find items advanced
$apicalla  = "$endpoint"
    ."callname=FindItemsAdvanced"
    ."&version=$version"
    ."&siteid=0"
    ."&appid=$appID"
    ."&MaxEntries=10"
    ."&ItemSort=EndTime"
    ."&ItemType=AllItemTypes"
    ."&IncludeSelector=SearchDetails"
    ."&responseencoding=$responseEncoding";

    $resp = simplexml_load_file($apicalla);

this call is the equivalent to

http://open.api.ebay.com/shopping?callname=FindItemsAdvanced&version=631&siteid=0&appid=asdf3e6e3&MaxEntries=10&ItemSort=EndTime&ItemType=AllItemTypes&IncludeSelector=SearchDetails&responseencoding=XML

My question is what am I missing to make this simple search call?

2

Answers


  1. It looks like you’re trying to use eBay’s Shopping API, specifically the FindItemsAdvanced call which I believe was deprecated quite some time ago and may no longer be functional (I no longer see it in the call reference). What you want to do is use use findItemsAdvanced from eBay’s Finding API.

    First, you’ll need to change your API endpoint & query string parameters a bit (see the aforementioned findItemsAdvanced call reference for the specifics, but I believe it’ll look more like this (I haven’t touched my findItemsAdvanced calls in at least 6 months, so I haven’t tested this):

    $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1?';  
    $responseEncoding = 'XML';   
    $version = '1.8.0';   // API version number (they're actually up to 1.11.0 at this point
    $appID   = 'asdf3e6e3'; 
    $itemSort  = "EndTimeSoonest";
    
    //find items advanced
    $apicalla  = "$endpoint"
        ."OPERATION-NAME=findItemsAdvanced"
        ."&SERVICE-VERSION=$version"
        ."&GLOBAL-ID=EBAY-US"
        ."&SECURITY-APPNAME=$appID"
        //."&MaxEntries=10"    // look for an equivalent for this (maybe paginationInput.entriesPerPage?)
        ."&sortOrder=EndTimeSoonest"
        //."&ItemType=AllItemTypes"   // not needed AFAICT, otherwise look at itemFilterType
    ."&descriptionSearch=true";
        ."& RESPONSE-DATA-FORMAT=$responseEncoding";
    
    $resp = simplexml_load_file($apicalla);
    

    In addition to this, to use findItemsAdvanced, you must specify what you’re searching for either by category (categoryId) or by keywords (keywords), hence the “Please specify a query!” error message.

    So, you also need to add something like the following (assuming keywords):

    $keywords = "something";
    $apicalla .= "&keywords=" . urlencode($keywords);
    

    Giving you the following:

    $endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1?';  
    $responseEncoding = 'XML';   
    $version = '1.8.0';   // API version number (they're actually up to 1.11.0 at this point
    $appID   = 'asdf3e6e3'; 
    $itemSort  = "EndTimeSoonest";
    $keywords = "something";    // make sure this is a valid keyword or keywords
    
    //find items advanced
    $apicalla  = "$endpoint"
        ."OPERATION-NAME=findItemsAdvanced"
        ."&SERVICE-VERSION=$version"
        ."&GLOBAL-ID=EBAY-US"
        ."&SECURITY-APPNAME=$appID"
        //."&MaxEntries=10"    // look for an equivalent for this (maybe paginationInput.entriesPerPage?)
        ."&sortOrder=$itemSort"
        //."&ItemType=AllItemTypes"   // not needed AFAICT, otherwise look at itemFilterType
        ."&descriptionSearch=true";
        ."& RESPONSE-DATA-FORMAT=$responseEncoding"
        ."&keywords=" . urlencode($keywords);
    
    $resp = simplexml_load_file($apicalla);
    

    One final note: If you want to load further details of specific items that you find in your results, you’ll still want to use the Shopping API (specifically the GetSingleItem & GetMultipleItems calls). So, you may ultimately use a mix of the Shopping & Finding APIs.

    Login or Signup to reply.
  2. It should be something like:

    <?php
    $url = 'http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.11.0&SECURITY-APPNAME=YOUR_APP_ID&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&paginationInput.entriesPerPage=2&keywords=ipod&siteid=203&GLOBAL-ID=EBAY-IN';
    $xml = file_get_contents( $url );
    $xml = simplexml_load_string( $url );
    ?>
    

    Log-in to your ebay developer account and click on this link: Test your calls with API Test Tool

    Hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search