skip to Main Content

I would like to get the item URL based on the item ID. After searching, I found that I can use GetSingleItem to achieve my goal. However, I got an error:

eBay returned the following error(s):
2 : Unsupported API call.
The API call “GetSingleItem” is invalid or not supported in this release.

Here is my code (all configuration are correct because I can use GetOrders by using these configs):

$subverb = "GetSingleItem";

$requestXmlBody = '<?xml version="1.0" encoding="utf-8" ?>';
$requestXmlBody .= '<GetSingleItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
$requestXmlBody .= "<ItemID>111986554711</ItemID>";
$requestXmlBody .= '</GetSingleItemRequest>';

//Create a new eBay session with all details pulled in from included keys.php
$session = new eBaySession($userToken, $devID, $appID, $certID, $serverUrl, $compatabilityLevel, $siteID, $subverb);

//send the request and get response
$responseXml = $session->sendHttpRequest($requestXmlBody);
if (stristr($responseXml, 'HTTP 404') || $responseXml == '')
     die('<P>Error sending request');

//Xml string is parsed and creates a DOM Document object
$responseDoc = new DomDocument();
$responseDoc->loadXML($responseXml);

//get any error nodes
$errors = $responseDoc->getElementsByTagName('Errors');
$response = simplexml_import_dom($responseDoc);
$entries = $response->PaginationResult->TotalNumberOfEntries;

//if there are error nodes
if ($errors->length > 0) {
   echo '<P><B>eBay returned the following error(s):</B>';
   //display each error
   //Get error code, ShortMesaage and LongMessage
   $code = $errors->item(0)->getElementsByTagName('ErrorCode');
   $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage');
   $longMsg = $errors->item(0)->getElementsByTagName('LongMessage');

   //Display code and shortmessage
   echo '<P>', $code->item(0)->nodeValue, ' : ', str_replace(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue));

   //if there is a long message (ie ErrorLevel=1), display it
   if (count($longMsg) > 0)
       echo '<BR>', str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue));
   } else { //If there are no errors, continue
      if (isset($_GET['debug'])) {
         header("Content-type: text/xml");
         print_r($responseXml);
      } else {
         print("n; 111986554711: " . $response->Item->ViewItemURLForNaturalSearch);
      }
   }

Any suggestion? Thank you .

2

Answers


  1. Chosen as BEST ANSWER

    I got an answer without using api. Here is the answer: after I got item ID, I can use "http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=".$item_id to show my product on ebay.

    I found this uri by using GetOrders API.

    OrderArray.Order .TransactionArray.Transaction .Variation .VariationViewItemURL

    Tip: "not optimized for natural search"

    If anyone has any idea about "GetSingleItem", I am willing to know why my code doesn't work.


  2. As you discovered, you don’t need the API to construct a simple eBay view item landing page URL.

    The URL format you discovered works, but it’s very old and might not be supported in full or for much longer.

    Here’s a simple URL format that is pretty current that you can use:

    http://www.ebay.com/itm/122225724269

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