简体   繁体   English

我试图在PHP中使用亚马逊api代码,但它给了我错误的不支持版本以下是我的代码

[英]I am trying to use amazon api code in php but it is giving me error of not supported version following is my code

following is the code which i am using with php to get xml response with amazon api service but it is giving me error stated as below of code. 以下是我使用PHP与amazon api服务获取xml响应的代码,但它给出了我的错误,如下面的代码所示。

<?php

// Your AWS Access Key ID, as taken from the AWS Your Account page
$aws_access_key_id = "A*********A";

// Your AWS Secret Key corresponding to the above ID, as taken from the AWS Your Account page
$aws_secret_key = "ue*******s+";

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

$uri = "/onca/xml";

$params = array(
    "Service" => "AWSECommerceService",
    "Operation" => "ItemSearch",
    "AWSAccessKeyId" => "AKIAJYSYWXDOF5CWIK5A",
    "AssociateTag" => "unity0f-21",
    "SearchIndex" => "All",
    "Keywords" => "iphone",
    "ResponseGroup" => "Images,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, $aws_secret_key, true));

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

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

?>

it is giving error as unsupported version i tried everything but still error is occurring please help 它给出错误作为不支持的版本我尝试了一切但仍然发生错误请帮助
response of the request for the xml file is as following: 对xml文件的请求的响应如下:

 <?xml version="1.0"?>
    <ItemSearchErrorResponse
        xmlns="http://ecs.amazonaws.com/doc/2005-10-05/">
        <Error>
            <Code>UnsupportedVersion</Code>
            <Message>Version 2005-10-05 is unsupported. Please use 2011-08-01 or greater instead.</Message>
        </Error>
        <RequestId>9f95a47d-f593-4002-af01-85b1b12fdf2d</RequestId>
    </ItemSearchErrorResponse>

Add a valid version to your $params array, eg: 在$ params数组中添加有效版本,例如:

"ResponseGroup" => "Images,ItemAttributes,Offers",
"Version" => "2015-10-01"

I tested your script and found it works with the above. 我测试了你的脚本,发现它适用于上面的内容。

The cause of the issue seems to be that the API defaults to a deprecated value if you omit the version parameter. 如果省略version参数,问题的原因似乎是API默认为不推荐使用的值。

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

相关问题 我正在尝试通过串行端口与微控制器通信。 但是我的PHP脚本给我一个错误 - I am trying to communicate with a micro controller through a serial port . but my php script is giving me an error 我有两个PHP代码块正在给我错误: - I have two chunk of PHP code which is giving me the error: 我在以下 php 代码中遇到搜索错误 - I am having search error in following php code 运行代码时出现以下错误 - I am getting following error while running my code 我正在尝试使我的php主类压缩并像正常的php代码一样使用它 - I am trying to make my php main class compress and use it like normal php code 我的登录代码不断给我一个错误 - My login code keeps giving me an error 提交表单按钮时我没有得到输出 PHP 电子邮件代码没有给我结果 - I am not getting output when submitting a Form button PHP email code is not giving me result 我正在尝试通过 php 从我的联系我们页面向 email 发送 email 但它给出了错误我的代码和错误如下 - i am trying to send an email from my contact us page to email by php but it gives error my code and error given below 我在php中的搜索引擎代码没有任何结果 - My Search engine code in php giving me no result 我的 php 代码没有向 mySQL 输入数据并且没有给我任何反馈 - My php code is not inputting data to mySQL and giving me no feedback
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM