dounianluo0086 2016-10-24 13:06
浏览 53
已采纳

如何根据商品ID获取易趣物品网址

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("
; 111986554711: " . $response->Item->ViewItemURLForNaturalSearch);
      }
   }

Any suggestion? Thank you .

  • 写回答

2条回答 默认 最新

  • douyao1856 2016-11-18 09:45
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 jupyter notebook如何添加libGL.so.1库
  • ¥20 easyPoi能否实现下拉多选或者复选框
  • ¥15 网桥在转发帧时,会变帧的源地址和目的地址吗?
  • ¥15 用Multisim设计汽车尾灯控制电路
  • ¥100 求用matlab求解上述微分方程的程序代码
  • ¥15 MAC安装佳能LBP2900驱动的网盘提取码
  • ¥400 微信停车小程序谁懂的来
  • ¥15 ATAC测序到底用什么peak文件做Diffbind差异分析
  • ¥15 安装ubantu过程中第一个vfat 文件挂载失败
  • ¥20 GZ::CTF如何兼容一些靶机?