eBay API返回低分辨率缩略图,而不是卖家上传的图像 [英] eBay API returns low resolution thumbnails instead of the image uploaded by seller

查看:64
本文介绍了eBay API返回低分辨率缩略图,而不是卖家上传的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用eBay的API时,列表显示的是低分辨率缩略图,而不是卖方上传的高分辨率版本。我必须更改代码中的哪些内容才能解决此问题?我在eBays API论坛上研究了解决方案,但它似乎与本教程中使用的代码无关。



Javascript代码:

 < div id = api >< / div> 

< script>
函数_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 ='+图片+' border = 0 width = 190>'+'< a href ='+ viewitem +' target = _ blank>'+标题+
'< / a>< / td>< / tr>'));
}
}
html.push(’< / tbody>< / table>’);
document.getElementById( api)。innerHTML = html.join();
}


//创建要在请求中使用的项目过滤器的JavaScript数组
var filterarray = [
{ name : MaxPrice,
value: 500,
paramName:货币,
paramValue: USD},
{ name : MinPrice,
value: 200,
paramName:货币,
paramValue: USD},
{ name : FreeShippingOnly,
value: true,
paramName:,
paramValue:},
{ name: ListingType,
value:[ FixedPrice],
paramName:,
paramValue:},
];

//为URL过滤器定义全局变量
var urlfilter =;


//从项目过滤器数组生成索引URL片段
function buildURLArray(){
//遍历数组$ b $中的每个过滤器b for(var i = 0; i< filterarray.length; i ++){
//为filterarray
中的每个项目过滤器建立索引var itemfilter = filterarray [i];
//遍历每个项目过滤器中的每个参数
for(itemfilter中的var index){
//检查参数是否有值(有些没有)
if(itemfilter [index]!==){
if(数组的itemfilter [index]实例){
for(var r = 0; r< itemfilter [index] .length; r ++) {
var value = itemfilter [index] [r];
urlfilter + =& itemFilter\( + i + \)。 +索引+ \( + r + \)= +值;
}
}
else {
urlfilter + =& itemFilter\( + i + \)。 +索引+ = + itemfilter [index];
}
}
}
}
} //结束buildURLArray()函数

//执行该函数以构建URL过滤器
buildURLArray(filterarray);




< / script>


<!-
将您的appid的值用作以下appid参数。
->
< 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>


解决方案

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


  1. item.galleryURL; 替换为 item.pictureURLSuperSize;

  2. & paginationInput.entriesPerPage = 3
  3. $ li $ 之后添加& outputSelector = PictureURLSuperSize ol>

    这应该可以解决问题。确保使用相同的大小写结构。

    我撰写了一篇有关此问题的较长博客,并提供了更多示例这里


    When utilizing eBay's API, the listings show using the low res thumbnail pictures, rather than the high res version that the seller uploaded. What must I alter in the code to fix this? I've looked at solutions on eBays API forum, but it doesn't seem to be relevant to the code used in the tutorial.

    Javascript code:

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

    解决方案

    I struggled with this for a long time too. Make these changes:

    1. Replace item.galleryURL; with item.pictureURLSuperSize;
    2. Add &outputSelector=PictureURLSuperSize right after &paginationInput.entriesPerPage=3

    That should do the trick. Make sure to use the same capitalization structure.
    I wrote a longer blog post about this with more examples here

    这篇关于eBay API返回低分辨率缩略图,而不是卖家上传的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆