APi 易趣服务"findItemsByKeywords"不返回结果要求 (PHP)



我对Ebay API有问题,特别是服务或操作"findItemsByKeywords",因为根据您进行查询以返回结果的URL(itemSearchURL(,它与在屏幕上打印时返回我的URL非常不同。然后我给你看我的代码。

print_r($ebay= ebayapi("Xiaomi Redmi Note 7"));
function ebayapi($keyword) {
// API request variables
$endpoint = 'http://svcs.ebay.com/services/search/FindingService/v1';  // URL to call
$version = '1.13.0';  // API version supported by your application
$appid = '';  // Replace with your own AppID
$globalid = 'EBAY-ES';  // Global ID of the eBay site you want to search (e.g., EBAY-DE)
$safequery = urlencode($keyword);  // Make the query URL-friendly
$i = '0';  // Initialize the item filter index to 0
// Construct the findItemsByKeywords HTTP GET call 
$apicall = "$endpoint?";
$apicall .= "OPERATION-NAME=findItemsByKeywords";
$apicall .= "&SERVICE-VERSION=$version";
$apicall .= "&SECURITY-APPNAME=$appid";
$apicall .= "&GLOBAL-ID=$globalid";
$apicall .= "&keywords=$safequery";
$apicall .= "&categoryId=9355";
$apicall .= "&bestOfferEnabled=true";
$apicall .= "&SortOrderType=StartTimeNewest";
$apicall .= "&paginationInput.entriesPerPage=3";
$resp = simplexml_load_file($apicall);
$fiction=array();
if ($resp->ack == "Success") {
$results = '';
foreach($resp->searchResult->item as $item) {
$price  = $item->sellingStatus->currentPrice;
$title = $item->title;
$pic   = $item->galleryURL;
$url= $item->viewItemURL;
$title2=remove_accents($title);
$price2=(float)$price;
$uid= uniqid(about);
$uid2= uniqid(price);
$fiction[$uid]=  array('price' => $price2,
'priceOld' => '0',
'percentageSaved' => 0,
'currency' => '€',
'currencyCode' => 'EUR',
"manufacturer" => "",
"category" => "",
"categoryPath" => "",
"merchant" => "",
"logo" => "",
"domain" => "ebay.com",
"rating" => 4.5,
"reviewsCount"=>"",
"availability"=>"",
"orig_url"=>"$url",
"ean"=>"",
"upc"=>"",
"sku"=>"",
"isbn"=>"",
"woo_sync"=>"mobile",
"woo_attr"=>"",
"unique_id"=>$uid2,
"title"=>"$title2",
"description"=>"dezcripcion",
"img"=>"$pic",
"url"=>"$url",
"last_update"=>"1576704317",
"extra" => array("deeplink" => "")
);
}
return $fiction;
}
else {
return "AppID for the Production environment.";
}
}

据说,在对 API 响应进行var_dump时,您应该从以下 URL 获取数据:https://www.ebay.es/sch/i.html?_nkw=Xiaomi+Redmi+Note+7&_ddo=1&_ipg= 3 & _pgn = 1

但我没有从他们那里得到任何东西,或者至少没有按照想要的顺序,相反,我得到了"小米红米 Note 8 Pro 6GB 128GB 6.53"、"小米红米 Note 8 Pro 128GB 6.53" 智能手机 NFC 4500mAh 全球 ROM ",只有一个匹配"智能手机小米红米 NOTE 7 128GB 免费5379335"。我怎样才能提供更高的精度并管理给定的关键字?

谢谢

不要使用findItemsByKeywords,使用findItemsAdvanced。 我不认为他们多年来更新了findItemsByKeywords,人们报告了使用它的问题。 也就是说,我还听说您从API检索的结果与您在eBay上获得的结果不同。 在eBay上,搜索将是"模糊的",这意味着你更有可能得到你不想要的结果。 API 通常对您将收到的结果非常严格;如果您仅搜索项目标题,并搜索"小米红米 Note 7",则只会获得包含所有四个关键字的结果。

最新更新