Zurzeit haben wir ein kleines Problem und hoffen ihr könnt uns helfen.
Wir sind dabei eine Affiliate Webseite im KFZ Tuning zu erstellen.
Das Grundgerüst steht soweit, nun geht es ans Produkte einfügen per API Call.
Per Javascript wird eine Verbindung zum eBay Partnernetwork aufgebaut und mit dem FindByKeywords API Call Produkte abgerufen.
Leider bekommen wir es nicht ganz in den Griff nur das abzurufen, dass wir benötigen.
Wenn jetzt z.B. nach "Alfa Romeo 4C Alufelge" gesucht wird, sollen ja nur Ergebnisse für das Fahrzeug Alfa Romeo 4C angezeigt werden.
Jedoch kommen dann auch Ergebnisse vom Alfa Romeo Mito 4C6, weil im Titel "4C" vorkommt.
Nun haben wir uns überlegt, das ganze vielleicht per categorie ids zu filtern, jedoch bringt das nichts.
Das tiefste das wir finden konnten, war ein Filter nach Marke, in diesem Fall Alfa Romeo (wenn es da welche für einzelne Fahrzeuge gäbe, würden wir uns über einen Link freuen).
eBay selbst hat eine Filterfunktion und dann werden auch nur diese Ergebnisse angezeigt, es muss also möglich sein.
Im Seitenquelltext haben wir so etwas gefunden:
Code: Alles auswählen
(Passt für: Alfa Romeo 4C)</a>
Anbei mal noch das komplette Script und den Seitenquelltext von eBay:
Unser Javascript zur Abfrage:
Code: Alles auswählen
<div id="results" method="post" style="float:left;" name="results" onchange="function">
</div>
<script type="text/javascript">
/* <![CDATA[ */
function _cb_findItemsByKeywords(root) {
var items = root && root.findItemsByKeywordsResponse &&
root.findItemsByKeywordsResponse[0] &&
root.findItemsByKeywordsResponse[0].searchResult &&
root.findItemsByKeywordsResponse[0].searchResult[0] &&
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 shippingInfo = item.shippingInfo && item.shippingInfo[0] || {};
var sellingStatus = item.sellingStatus && item.sellingStatus[0] || {};
var listingInfo = item.listingInfo && item.listingInfo[0] || {};
var title = item.title;
var subtitle = item.subtitle || '';
var pic = item.galleryURL;
var viewitem = item.viewItemURL;
var currentPrice = sellingStatus.currentPrice && sellingStatus.currentPrice[0] || {};
var displayPrice = currentPrice['__value__'] + '€';
var buyItNowAvailable = listingInfo.buyItNowAvailable && listingInfo.buyItNowAvailable[0] === 'true';
var freeShipping = shippingInfo.shippingType && shippingInfo.shippingType[0] === 'Free';
if (null !== title && null !== viewitem) {
html.push(`
<tr>
<td class="image-container">
<img src="${pic}"border = "0">
<\/td>
<td class="data-container">
<a class="item-link" href="${viewitem}" target="_blank">
<p class="title">${title}<\/p>
<p class="subtitle">${subtitle}<\/p>
<p class="price">${displayPrice}<\/p>
${buyItNowAvailable ? '<p class="bin">Sofort Kaufen<\/p>' : ''}
${freeShipping ? '<p class="fs">Versandkostenfrei<\/p>' : ''}
<\/a>
<\/td>
<\/tr>
`);
}
}
html.push('<\/tbody><\/table>');
document.getElementById("results").innerHTML = html.join('');
}
/*]]>*/
</script>
<script src=
"https://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=BAFTunin-DFuchs-PRD-9796ade31-eb6822af&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsByKeywords&REST-PAYLOAD&keywords=Alufelge%20Alfa%20Romeo%204C%20Alufelge&paginationInput.entriesPerPage=8&GLOBAL-ID=EBAY-DE&siteid=77"></script>
https://pastebin.com/wUiyUzJb
Wenn uns jemand nur annähernd helfen könnte, vielleicht danach auch bezüglich anderer Probleme, wären wir sehr dankbar!
Außerdem frohe Ostern an alle.