gpt4 book ai didi

javascript - eBay API 返回低分辨率缩略图而不是卖家上传的图片

转载 作者:行者123 更新时间:2023-11-30 12:51:46 25 4
gpt4 key购买 nike

当使用 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>

最佳答案

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

关于javascript - eBay API 返回低分辨率缩略图而不是卖家上传的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20721404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com