2016-06-01 3 views
1

이베이 API 함수이베이 API를 findItemsAdvanced()는 변화 명부

findItemsAdvanced() or findItemsByKeywords() 

수익률 변동 목록에 대한 모든 변형에 대해 여러 개의 결과를 반환합니다. 같은 업체 정보에 대해 여러 개의 결과가 표시되지 않도록하려면 어떻게해야합니까?

현재 이베이의 내 페이지는 this listing 의 변형에서 그 중 하나를 수행하고 있습니다. 결과는 here입니다.

변형 결과를 목록 당 하나의 결과로 결합하려면 어떻게해야합니까?

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

조정할 필요가있는 곳을 볼 수 있도록 이미 가지고있는 코드를 보여줄 수 있습니까? – zombiecode

+0

@ JamesNewbert-Breen 나는 내 자신의 사용자 이름으로 eBay의 튜토리얼에서 간단한 코드를 추가했습니다 ... : http://developer.ebay.com/devzone/finding/howto/GettingStarted_JS_NV_JSON/GettingStarted_JS_NV_JSON.html –

답변

1

는 "HideDuplicateItems"항목 필터를 사용하여 시도 해 봤나 :

여기에 이베이에서 튜토리얼 쇼와 코드는?

앞으로 공개적으로 게시 할 때 항상 이베이 API 자격증을 마스킹하십시오.

+0

당신이 틀 렸습니다. . 이제 작동합니다. 어떻게 내가 신임장을 가려야하는지 말해 줄 수 있니? 그리고 그 문제는 무엇입니까. 감사합니다. @ helios825 –

+1

이 경우 귀하의 신임장은 귀하의 AppID이며 위의 코드에 공개적으로 표시됩니다. 다른 사용자는 AppID를 도용하여이를 악용하여 다양한 방법으로 eBay API에 액세스 할 수 있습니다. 그것을 숨기려면 원래 질문에서 "xxxxxxxxxxxxx"와 같은 것으로 편집하십시오. – helios825