question

all_vintage_cards avatar image
0 Likes"
all_vintage_cards asked

Adding EPN Header To Browse API Call

I'm not sure if I'm doing this correctly, wondering if anyone can take a look. The link that appears on my website does show as having campid=XXXX but i think it could be the fact that I'm double posting in the code.

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.ebay.com/buy/browse/v1/item_summary/search?q=motorcycle&sort=-price&category_ids=212",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "Content-Type:application/json",
        "Authorization: Bearer $token",
        "X-EBAY-C-MARKETPLACE-ID:EBAY_US",
        "X-EBAY-C-ENDUSERCTX:affiliateCampaignId=xxx,affiliateReferenceId=1483344",
    ),
  ));
  $response = curl_exec($curl);
  $err = curl_error($curl);
  curl_close($curl);


and then with the results, i was actually hard coding the campaign id in each link. Will this still work?


//Create the WordPress page content HTML
$pageHTML="<h2>Header</h2>";
$pageHTML.="<div class='wrapper'>";
//Loop through the API results
foreach($resp as $item) {
//Put each show into an html structure
//  Note: if your theme uses bootstrap use responsive classes here
$pageHTML.="<div class='show-wrapper'>";
//Not all items have a 'poster', so in that case use the img field
$pic = $item->image->imageUrl;
$itemID = $item->legacyItemId;
$link  = 'https://www.ebay.com/itm/'.$itemID.'?mkrid=xxx&siteid=0&mkcid=1&campid=xxx3&toolid=10001&mkevt=1&customId=harley';
$title = $item->title;
$price = $item->price->value;
$bids =  $item->bidCount;
if(empty($bids)){
    $bids = 0;
}

// For each SearchResultItem node, build a link and append it to $results
$results .= "<div class=\"item\"><div class=\"ui small image\"><a href=\"$link\" target=\"_blank\"><img height=\"200px\" width=\"130px\" src=\"$pic\"></a></div><div class=\"content\"><div class=\"header\"><a href=\"$link\" target=\"_blank\">$title</a></div><div class=\"meta\" style=\"margin-top:1.1em\"><span class=\"price\"><a href=\"$link\" target=\"_blank\"><button class=\"ui teal button\">watch watchers</button></a></span><div class=\"extra\"><button class=\"ui button\"><a href=\"$link\" target=\"_blank\"><b>Current Bids:</b> $bids </a></button></div><div class=\"extra\"><a href=\"$link\" target=\"_blank\"><button class=\"ui orange button\">Current Price: $$price</button></a></div><div class=\"description\"></div></div></div></div>";
 




browse api
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

foulfoot avatar image
0 Likes"
foulfoot answered

I don't know what you mean by "double posting". You're not using the affiliateURL field the API provides (which is fine; the URL they provide doesn't follow their own guidelines anyway.... :/ ), you're rolling your own link with the $link variable. And you already said your code works, so.... ?

Providing your campaign ID in the header is just to enable eBay to correlate your ePN campaigns with your API App ID. And probably, so they can ferret out folks who are sharing their App IDs between multiple ePN partners.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

all_vintage_cards avatar image
0 Likes"
all_vintage_cards answered

Ok, appreciate the clarification--thank you!

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.