服务“;findItemsByKeywords“;APi易趣不返回结果的精确性(PHP)

服务“;findItemsByKeywords“;APi易趣不返回结果的精确性(PHP),php,api,ebay-api,Php,Api,Ebay Api,我对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/serv

我对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_转储时,您应该从以下url获取数据:3&_pgn=1

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


谢谢

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

我已经尝试了您提到的服务,虽然略有改进,但我仍然发现屏幕上的搜索结果与它提到的url中的搜索结果不同,例如:“小米红米笔记8 Pro 128GB 6GB 6.53”智能手机NFC 4500mAh全球ROM“并且它不在:正如我所说的,eBay.com上的搜索是模糊的。所以在你的搜索链接上,我看到了“小米红米注8”。API可能会忽略单个数字,所以它会在标题中添加“小米红米注”。尝试使用一个不是单个字母或数字的关键字来缩小范围。