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条)

报告相同问题?

悬赏问题

  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?