我遇到了Ebay API的问题,尤其是服务或操作“ findItemsByKeywords”的问题,因为根据您查询返回结果的URL(itemSearchURL),它与在屏幕上打印时返回我。然后我告诉你我的代码。
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时,您应该从以下网址获取数据: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“。我如何才能提高精度,并控制给定的关键字?
谢谢