skip to Main Content

I’m trying to integrate eBay API in my project.
I use ZendFramework and there is library for eBay FindingAPI, but it doesn’t work for method findItemsByProduct.

For understanding problem I wrote my small class:

<?php
class MyProject_Model_Ebay 
{
    const FINDING_API_URL = 'http://svcs.ebay.com/services/search/FindingService/v1?';

    private $appId;

    public function __construct($appId)
    {
        $this->appId = $appId;
    }

    public function findByProduct($id, $type = 'UPC')
    {
        $params = array(
            'productId.@type' => $type,
            'productId' => $id,
        );

        return $this->doApiRequest('findItemsByProduct', $params);
    }

    public function findByKeywords($keywords)
    {
        $params = array(
            'keywords' => $keywords,
        );

        return $this->doApiRequest('findItemsByKeywords', $params);
    }


    private function doApiRequest($operationName, $payload)
    {

        $global = array(
            'OPERATION-NAME' => $operationName,
            'SECURITY-APPNAME' => $this->appId,
            'GLOBAL-ID' => 'EBAY-US',
            'SERVICE-VERSION' => '1.0.0',
            'MESSAGE-ENCODING' => 'UTF-8',
            'RESPONSE-DATA-FORMAT' => 'JSON',
        );

        $ret = file_get_contents(
            self::FINDING_API_URL . http_build_query($global) . '&REST-PAYLOAD&' . http_build_query($payload)
        );

        return $ret;
    }

}

Method findItemsByKeywords works OK, but findItemsByProduct still returns error

Invalid product ID value.

I tried different variants of passing value, but it doesn’t work 🙁 Current version of passing value I saw here: how to use python xml.etree.ElementTree to parse eBay API response?

Usage:

<?php
$eBay = new MyProject_Model_Ebay(
    'My-app-id'
);

$eBay->findByProduct('4719331316129');

Response:

{"findItemsByProductResponse":[{"ack":["Failure"],"errorMessage":[{"error":[{"errorId":["41"],"domain":["Marketplace"],"severity":["Error"],"category":["Request"],"message":["Invalid product ID value."],"subdomain":["Search"],"parameter":["4719331316129"]}]}],"version":["1.11.1"],"timestamp":["2012-03-14T06:41:42.600Z"]}]}

Important!
If i change GLOBAL-ID on EBAY-DE, for example, everything is OK! What’s wrong with EBAY-US?!

2

Answers


  1. Seems that you had passed incorrect product ID (itemID instead of ProductID).
    $eBay->findByProduct(‘4719331316129’); – 13 digits, when normally ProductId has 8-9 digits
    Compare:

    <item>
      <itemId>230823026330</itemId>
      <title>Apple iPhone 3G - 8GB - Black (AT&amp;T) Smartphone #26459</title>
      <globalId>EBAY-US</globalId>
      <primaryCategory>
        <categoryId>9355</categoryId>
        <categoryName>Cell Phones &amp; Smartphones</categoryName>
      </primaryCategory>
      <galleryURL>http://thumbs3.ebaystatic.com/pict/2308230263304040_1.jpg</galleryURL>
      <viewItemURL>http://www.ebay.com/itm/Apple-iPhone-3G-8GB-Black-AT-T-Smartphone-26459-/230823026330?pt=Cell_Phones</viewItemURL>
      <productId type="ReferenceID">101892398</productId>
    
    Login or Signup to reply.
  2. The Id you are sending is been treated as the UPC of a product.

    The findItemsByProduct requires
    productId

    type is must be specified while passing product id.
    Type can include ISBN, UPC, EAN, or ReferenceID (ePID).

    In your case, the ID you are passing is considered as the UPC number. So confirm whether the UPC is correct for that product.

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