APi Ebay的Service“ findItemsByKeywords”不返回结果精确度(PHP)

问题描述 投票:0回答:1

我对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

但是我没有从他们那里得到任何东西,或者至少没有以期望的顺序得到任何东西,相反,我得到了“小米Redmi Note 8 Pro 6GB 128GB 6.53”,“小米Redmi Note 8 Pro 128GB 6GB 6.53”智能手机NFC 4500mAh全球ROM“ ,只有一个具有匹配项“ SMARTPHONE XIAOMI REDMI NOTE 7 128GB FREE 5379335”。我如何才能提高精度,并控制给定的关键字?

谢谢

php api ebay-api
1个回答
0
投票

不使用findItemsByKeywords,请使用findItemsAdvanced。我认为他们几年来都没有更新findItemsByKeywords,并且人们报告了使用它的问题。也就是说,我也听说过,从API检索的结果将不同于您在eBay上获得的结果。在eBay上,搜索将是“模糊的”,这意味着您更有可能获得不需要的结果。 API对收到的结果通常非常严格;如果仅搜索项目标题,并且搜索“小米Redmi Note 7”,您将only

© www.soinside.com 2019 - 2024. All rights reserved.