question

all_vintage_cards avatar image
0 Likes"
all_vintage_cards asked

Problems with FindItemsAdvanced API

I have some PHP code I built a while back to pull some listings from eBay to show on my site.

I'm noticing that any aspect filters that I've built are no longer working.

It looks something like this:

Did anything change? Does this code look ok?

// API request variables
$endpoint = 'https://svcs.ebay.com/services/search/FindingService/v1';  // URL to call
$version = '1.0.0';  // API version supported by your application
$appid = 'XXXXX';  // Replace with your own AppID
$globalid = 'EBAY-US';  // Global ID of the eBay site you want to search (e.g., EBAY-DE)
$query = 'Rookie Card';  // You may want to supply your own query
$safequery = urlencode($query);  // Make the query URL-friendly

$i = '0';  // Initialize the item filter index to 0

// Create a PHP array of the item filters you want to use in your request
$filterarray =
  array(
    array(
    'name' => 'MaxPrice',
    'value' => '100000',
    'paramName' => 'Currency',
    'paramValue' => 'USD'),
    array(
        'name' => 'MinPrice',
        'value' => '500',
        'paramName' => 'Currency',
        'paramValue' => 'USD'),
  );

if(!function_exists(CurrencyFormat)){
  function CurrencyFormat($number)
  {
     $decimalplaces = 2;
     $decimalcharacter = '.';
     $thousandseparater = ',';
     return number_format($number,$decimalplaces,$decimalcharacter,$thousandseparater);
  }
}

// Generates an indexed URL snippet from the array of item filters
if(!function_exists(buildURLArray)){
function buildURLArray ($filterarray) {
    global $urlfilter;
    global $i;
    // Iterate through each filter in the array
    foreach($filterarray as $itemfilter) {
      // Iterate through each key in the filter
      foreach ($itemfilter as $key =>$value) {
        if(is_array($value)) {
          foreach($value as $j => $content) { // Index the key for each value
            $urlfilter .= "&itemFilter($i).$key($j)=$content";
          }
        }
        else {
          if($value != "") {
            $urlfilter .= "&itemFilter($i).$key=$value";
          }
        }
      }
      $i++;
    }
    return "$urlfilter";
  } // End of buildURLArray function
}

  
  // Build the indexed item filter URL snippet
  buildURLArray($filterarray);

// Construct the findItemsByKeywords HTTP GET call
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findItemsAdvanced";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&keywords=$safequery";
$apicall .= "&categoryId=214";
$apicall .= "&aspectFilter(0).aspectName=Year";
$apicall .= "&aspectFilter(0).aspectValueName=1950|1951|1952|1953|1954|1955|1956|1957|1958|1959|1960|1961|1962|1963|1964|1965|1966|1967|1968|1969|1970|1971|1972|1973|1974|1975|1976|1977|1978|1979|1980";
$apicall .= "&affiliate.trackingId=XXXX";
$apicall .= "&affiliate.networkId=9";
$apicall .= "&affiliate.customId=XXXXX";
$apicall .= "&paginationInput.entriesPerPage=30";
$apicall .= "&sortOrder=WatchCountDecreaseSort";

$apicall .= "$urlfilter";

// Load the call and capture the document returned by eBay API
$resp = simplexml_load_file($apicall);
finding apifinditemsadvanced-finding
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

alvisinwales avatar image
0 Likes"
alvisinwales answered

Category ID 214 (Sports Memorabilia > Sports Trading Cards > Basketball Cards) no longer exists.


Maybe you need to use :

Sports Memorabilia > Sports Trading Cards > Trading Card Singles (261328)

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sagar_developersupport avatar image
0 Likes"
sagar_developersupport answered

Hi @all_vintage_cards,

For getting the all of the latest and supported category hierarchy for a eBay marketplace, please follow the steps mentioned below:

1. Firstly, you need to call GetDefaultCategoryTreeId to retrieve a reference to the default category tree associated with the specified eBay marketplace ID.

Ref:https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getDefaultCategoryTreeId

2. After getting the category_tree_id make a GetCategoryTree call to retrieve the complete category tree that is identified by the category_tree_id parameter.

Ref: https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getCategoryTree

3. Make GetItemAspectsForCategory call for the category to get the latest VariationSpecifics/Aspects. To learn more about the category tree structure, please take an overview of the Taxonomy API by going through the link given below:

Ref: https://developer.ebay.com/api-docs/commerce/taxonomy/static/overview.html

Best regards,
eBay Developer Support

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.