eBay API findItemsAdvanced() returns 变体列表的重复结果
eBay API findItemsAdvanced() returns duplicate results for variation listings
eBay API 功能
findItemsAdvanced() or findItemsByKeywords()
return 变体列表的所有变体。如何防止同一列表获得多个结果?
目前,我在 eBay 上的页面正在根据 this listing 的变体执行此操作
你可以看到结果 here.
如何将变体结果合并为每个列表的一个结果?
这是来自 eBay 的教程显示的代码:
<html>
<head>
<title>eBay Search Results</title>
<style type="text/css">body { font-family: arial,sans-serif;} </style>
</head>
<body>
<h1>eBay Search Results</h1>
<div id="results"></div>
<script>
// Parse the response and build an HTML table to display search results
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><td>' + '<img src="' + pic + '" border="0">' + '</td>' +
'<td><a href="' + viewitem + '" target="_blank">' + title + '</a></td></tr>');
}
}
html.push('</tbody></table>');
document.getElementById("results").innerHTML = html.join("");
} // End _cb_findItemsByKeywords() function
// Create a JavaScript array of the item filters you want to use in your request
var filterarray = [
{"name":"Seller",
"value":"gavdials-com"},
//{"name":"FreeShippingOnly",
//"value":"true",
//"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 paramter 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);
// Construct the request
// Replace MyAppID with your Production AppID
var url = "http://svcs.ebay.com/services/search/FindingService/v1";
url += "?OPERATION-NAME=findItemsByKeywords";
url += "&SERVICE-VERSION=1.0.0";
url += "&SECURITY-APPNAME=MyAppID";
url += "&GLOBAL-ID=EBAY-US";
url += "&RESPONSE-DATA-FORMAT=JSON";
url += "&callback=_cb_findItemsByKeywords";
url += "&REST-PAYLOAD";
url += "&keywords=markers";
url += "&paginationInput.entriesPerPage=100";
url += urlfilter;
// Submit the request
s=document.createElement('script'); // create script element
s.src= url;
document.body.appendChild(s);
// Display the request as a clickable link for testing
document.write("<a href=\"" + url + "\">" + url + "</a>");
</script>
</body>
</html>
您是否尝试过使用项目过滤器 "HideDuplicateItems"?
另外,以后公开发帖时一定要掩盖您的 eBay API 凭据。
eBay API 功能
findItemsAdvanced() or findItemsByKeywords()
return 变体列表的所有变体。如何防止同一列表获得多个结果?
目前,我在 eBay 上的页面正在根据 this listing 的变体执行此操作 你可以看到结果 here.
如何将变体结果合并为每个列表的一个结果?
这是来自 eBay 的教程显示的代码:
<html>
<head>
<title>eBay Search Results</title>
<style type="text/css">body { font-family: arial,sans-serif;} </style>
</head>
<body>
<h1>eBay Search Results</h1>
<div id="results"></div>
<script>
// Parse the response and build an HTML table to display search results
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><td>' + '<img src="' + pic + '" border="0">' + '</td>' +
'<td><a href="' + viewitem + '" target="_blank">' + title + '</a></td></tr>');
}
}
html.push('</tbody></table>');
document.getElementById("results").innerHTML = html.join("");
} // End _cb_findItemsByKeywords() function
// Create a JavaScript array of the item filters you want to use in your request
var filterarray = [
{"name":"Seller",
"value":"gavdials-com"},
//{"name":"FreeShippingOnly",
//"value":"true",
//"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 paramter 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);
// Construct the request
// Replace MyAppID with your Production AppID
var url = "http://svcs.ebay.com/services/search/FindingService/v1";
url += "?OPERATION-NAME=findItemsByKeywords";
url += "&SERVICE-VERSION=1.0.0";
url += "&SECURITY-APPNAME=MyAppID";
url += "&GLOBAL-ID=EBAY-US";
url += "&RESPONSE-DATA-FORMAT=JSON";
url += "&callback=_cb_findItemsByKeywords";
url += "&REST-PAYLOAD";
url += "&keywords=markers";
url += "&paginationInput.entriesPerPage=100";
url += urlfilter;
// Submit the request
s=document.createElement('script'); // create script element
s.src= url;
document.body.appendChild(s);
// Display the request as a clickable link for testing
document.write("<a href=\"" + url + "\">" + url + "</a>");
</script>
</body>
</html>
您是否尝试过使用项目过滤器 "HideDuplicateItems"?
另外,以后公开发帖时一定要掩盖您的 eBay API 凭据。