繁体   English   中英

如何使用PA API在网站上获取产品价格

[英]How to get product price on website with PA API

因此,我完全不熟悉AWS,起初看起来非常复杂。 我的计划是使用他们的ASIN在我的网站上获得产品价格。 因此,我去了便笺簿并尽了最大的努力,但是无论我做什么,我都会遇到503错误,并说我正在迅速发送许多请求,但事实并非如此。 在过去2天中,我尝试了4-5次,但仍然存在相同的错误。

在支持论坛中,我发现有人遇到类似的问题,并回答了一些问题,指出新规则仅使高利润的网站能够发送请求。 现在我的网站应该比较价格,并且不显示最新价格,我的利润将达不到我可以发送请求的程度。 这是Scratchpad给我的:

 <?php

 // Your Access Key ID, as taken from the Your Account page
 $access_key_id = "Here is my access key";

 // Your Secret Key corresponding to the above ID, as taken from the Your                Account page
 $secret_key = "Here is my secret key";

 // The region you are interested in
 $endpoint = "webservices.amazon.de";

 $uri = "/onca/xml";

 $params = array(
     "Service" => "AWSECommerceService",
     "Operation" => "ItemLookup",
     "AWSAccessKeyId" => "Here is my access-key",
     "AssociateTag" => "veganvergleic-21",
     "ItemId" => "B078B745K3",
     "IdType" => "ASIN",
     "ResponseGroup" => "ItemAttributes,Offers"
 );

 // Set current timestamp if not set
 if (!isset($params["Timestamp"])) {
     $params["Timestamp"] = gmdate('Y-m-d\TH:i:s\Z');
 }

 // Sort the parameters by key
 ksort($params);

 $pairs = array();

 foreach ($params as $key => $value) {
     array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
 }

 // Generate the canonical query
 $canonical_query_string = join("&", $pairs);

 // Generate the string to be signed
 $string_to_sign = "GET\n".$endpoint."\n".$uri."\n".$canonical_query_string;

 // Generate the signature required by the Product Advertising API
 $signature = base64_encode(hash_hmac("sha256", $string_to_sign,      $secret_key, true));

 // Generate the signed URL
 $request_url =      'https://'.$endpoint.$uri.'?'.$canonical_query_string.'&Signature='.rawurlenco     de($signature);

 echo "Signed URL: \"".$request_url."\"";

 ?>

因此,如果我所做的事情没有错,并且没有发送请求的方式,我如何使用ASIN在我的网站上获得价格? 我没有足够的想法来使它起作用。

任何帮助深表感谢!

如果您的销售量不大,Amazon产品广告API将无法正常运行。 如果您不这样做,则需要自己对其进行爬取或使用其他第三方API。 我们使用RapidAPI的amazon-price API,它支持单个请求中多达1000种产品的价格/评分/评论计数获取。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM