【问题标题】:eBay API returns low resolution thumbnails instead of the image uploaded by sellereBay API 返回低分辨率缩略图而不是卖家上传的图片
【发布时间】:2013-12-21 17:05:48
【问题描述】:

在使用 eBay 的 API 时,列表使用低分辨率缩略图显示,而不是卖家上传的高分辨率版本。我必须在代码中更改什么来解决这个问题?我在 eBays API 论坛上查看了解决方案,但它似乎与教程中使用的代码无关。

Javascript 代码:

<div id="api"></div>

<script>
function _cb_findItemsByKeywords(root)
{
  var items = root.findItemsByKeywordsResponse[0].searchResult[0].item || [];
  var html = [];
  html.push('<table width="100%" border="0" cellspacing="0" cellpadding="3"><tbody>');

  for (var i = 0; i < items.length; ++i)  
  {
    var item     = items[i];
    var title    = item.title;
    var pic      = item.galleryURL;
    var viewitem = item.viewItemURL;

    if (null != title && null != viewitem)
    {
      html.push(
        '<tr id="api_microposts"><td>'
         + '<img src="' + pic + '" border="0" width="190">' + '<a href="' + viewitem + '" target="_blank">' + title + 
         '</a></td></tr>');
    }
  }
  html.push('</tbody></table>');
  document.getElementById("api").innerHTML = html.join("");
}


// Create a JavaScript array of the item filters you want to use in your request
var filterarray = [
  {"name":"MaxPrice",
   "value":"500",
   "paramName":"Currency",
   "paramValue":"USD"},
   {"name":"MinPrice",
   "value":"200",
   "paramName":"Currency",
   "paramValue":"USD"},
  {"name":"FreeShippingOnly",
   "value":"true",
   "paramName":"",
   "paramValue":""},
  {"name":"ListingType",
   "value":["FixedPrice"],
   "paramName":"",
   "paramValue":""},
  ];

// Define global variable for the URL filter
var urlfilter = "";


// Generates an indexed URL snippet from the array of item filters
function  buildURLArray() {
  // Iterate through each filter in the array
  for(var i=0; i<filterarray.length; i++) {
    //Index each item filter in filterarray
    var itemfilter = filterarray[i];
    // Iterate through each parameter in each item filter
    for(var index in itemfilter) {
      // Check to see if the parameter has a value (some don't)
      if (itemfilter[index] !== "") {
        if (itemfilter[index] instanceof Array) {
          for(var r=0; r<itemfilter[index].length; r++) {
          var value = itemfilter[index][r];
          urlfilter += "&itemFilter\(" + i + "\)." + index + "\(" + r + "\)=" + value ;
          }
        }
        else {
          urlfilter += "&itemFilter\(" + i + "\)." + index + "=" + itemfilter[index];
        }
      }
    }
  }
}  // End buildURLArray() function

// Execute the function to build the URL filter
buildURLArray(filterarray);




</script>


<!--
Use the value of your appid for the appid parameter below.
-->
<script src=http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APPNAME*&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=iphone%205%2016gb%20unlocked&paginationInput.entriesPerPage=3>
</script>

【问题讨论】:

    标签: javascript ruby-on-rails ebay-api


    【解决方案1】:

    默认情况下,Finding API 返回一个 140 像素的缩略图。您必须在 API 调用中指定 outputSelector 才能检索更大的缩略图(400 像素或 800 像素)。在调用中添加 outputSelector=PictureURLLargeoutputSelector=PictureURLSuperSize 应该会使其返回更大图像的 URL。

    【讨论】:

    • 根据教程,页面底部的链接是API调用。但是,当我尝试将这些输出选择器中的任何一个添加到 url 时,图片仍然很小。这不是放置它的正确位置吗?
    【解决方案2】:

    我也为此苦苦挣扎了很长时间。进行以下更改:

    1. item.galleryURL; 替换为 item.pictureURLSuperSize;
    2. &paginationInput.entriesPerPage=3 之后添加 &outputSelector=PictureURLSuperSize

    这应该可以解决问题。确保使用相同的大小写结构。
    我写了一篇更长的博客文章,其中包含更多示例here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-27
      • 2018-09-10
      • 2011-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 2017-11-25
      相关资源
      最近更新 更多