php - Ebay API - Search my listing by keyword in title - Stack Overflow

I am trying to get data using the Ebay API and a keyword for my items.For example, I used to be able

I am trying to get data using the Ebay API and a keyword for my items. For example, I used to be able to enter this...

;SECURITY-APPNAME=MYAPPNAME&keywords=CHEESE&itemFilter.name=Seller&itemFilter.value=MY_USER_ID

Each of my titles is unique, so if I wanted to search the titles of my items and find the one that had the word "cheese" in it, entering the URL above would show me data for that item. I'd get xml code showing the full title, selling price, itemID, etc.

Just recently, this stopped working. I don't think you can use the FindingAPI anymore, and I don't think you can enter this on a URL. Can I somehow use PHP and cURL to get the item data based on a keyword?

I am trying to get data using the Ebay API and a keyword for my items. For example, I used to be able to enter this...

https://svcs.ebay/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SECURITY-APPNAME=MYAPPNAME&keywords=CHEESE&itemFilter.name=Seller&itemFilter.value=MY_USER_ID

Each of my titles is unique, so if I wanted to search the titles of my items and find the one that had the word "cheese" in it, entering the URL above would show me data for that item. I'd get xml code showing the full title, selling price, itemID, etc.

Just recently, this stopped working. I don't think you can use the FindingAPI anymore, and I don't think you can enter this on a URL. Can I somehow use PHP and cURL to get the item data based on a keyword?

Share Improve this question asked Mar 8 at 3:29 CheeseFlavoredCheeseFlavored 2,1242 gold badges24 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

As of 2025/02/04, Ebay Finding API is decommissioned. You can check the status of the Ebay API's here.

Instead of the Finding API, you can use the Browse API. Specifically you can search items by keyword using the items_search API end point.

Example:

https://api.ebay/buy/browse/v1/item_summary/search?q=cheese

Update based on the comment

You can finetune the search by using the various parameters. For example you can filter the results by specific sellers using the filter parameter.

Example:

https://api.ebay/buy/browse/v1/item_summary/search?q=cheese&filter=sellers:{seller_1|seller_2}

Full Code

<?php

//generate token with your client_id and client_secret
$hash = base64_encode($client_id . ':' . $client_secret);

$oauth_url = "https://api.ebay/identity/v1/oauth2/token";
$post_fields = "grant_type=client_credentials&scope=https%3A%2F%2Fapi.ebay%2Foauth%2Fapi_scope";

// Make the curl request to get the access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $oauth_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$hash));

$exec = curl_exec($ch);
$x = curl_error($ch);

$access_token = json_decode($exec)->access_token;

// Now make the request to the Browse API
$url = 'https://api.ebay/buy/browse/v1/item_summary/search?q=cheese&filter=sellers:{lehmans|jaymar718925|goafogo}';
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_HTTPHEADER, array( 'Authorization:Bearer '.$access_token));

$exec = curl_exec($ch);
$x = curl_error($ch);

echo '<pre>';
print_r(json_decode($exec));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744904036a4600146.html

相关推荐

  • php - Ebay API - Search my listing by keyword in title - Stack Overflow

    I am trying to get data using the Ebay API and a keyword for my items.For example, I used to be able

    1天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信