提交亚马逊 MWS CreateInboundShipmentPlan 时出现错误 "InvalidAddress"
Getting error "InvalidAddress" while submitting Amazon MWS CreateInboundShipmentPlan
我正在使用亚马逊 MWS CreateInboundShipmentPlan 创建装运计划,如果我将我的产品限制在 23-24 岁以下,它工作得很好,但如果我尝试提交超过 24 岁,它会给我 InvalidAddress 错误。
我正在使用 PHP API 向亚马逊 MWS 提交请求。在最初的故障排除中,我认为这完全与 URL 长度有关,因为如果我通过添加更多 SKU 来增加 URL 长度,它就会开始出现问题。
- 如果我尝试使用有限数量的 SKU,我会得到成功的结果。
但如果我尝试使用更多 SKU,它会给我
[错误] => 数组
(
[类型] => 发件人
[代码] => 无效地址
[消息] => 在此服务器上找不到资源 /errors/mws.amazonservices.com/500.html。
)
这是我的 PHP 代码。
function amazon_CreateInboundShipmentPlan($amazonAWSAccessKeyId,$amazonSellerId,$amazonMWSAuthToken,$amazonMarketPlaceId,$amazonSecretKey,$domain,$extras){
$param = array();
$param['AWSAccessKeyId'] = $amazonAWSAccessKeyId;
$param['Action'] = 'CreateInboundShipmentPlan';
$param['SellerId'] = $amazonSellerId;
$param['MWSAuthToken'] = $amazonMWSAuthToken;
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\0\0\0\Z", time());
$param['Version'] = '2010-10-01';
$param = array_merge($param,$extras);
$secret = $amazonSecretKey;
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
$amazon_feed = '';
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.'.$domain.'' . "\n";
$sign .= '/FulfillmentInboundShipment/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($amazon_feed, true));
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.".$domain."/FulfillmentInboundShipment/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
echo strlen($link)."\n";
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$errors=curl_error($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
return $array;
}
我认为 URL 长度有问题。请帮我弄清楚这段代码到底出了什么问题。
终于找到问题了。这是一个 url 限制问题 我将发布数据的方法从 GET 更改为 POST 并解决了问题。
我正在使用亚马逊 MWS CreateInboundShipmentPlan 创建装运计划,如果我将我的产品限制在 23-24 岁以下,它工作得很好,但如果我尝试提交超过 24 岁,它会给我 InvalidAddress 错误。 我正在使用 PHP API 向亚马逊 MWS 提交请求。在最初的故障排除中,我认为这完全与 URL 长度有关,因为如果我通过添加更多 SKU 来增加 URL 长度,它就会开始出现问题。
- 如果我尝试使用有限数量的 SKU,我会得到成功的结果。
但如果我尝试使用更多 SKU,它会给我
[错误] => 数组 ( [类型] => 发件人 [代码] => 无效地址 [消息] => 在此服务器上找不到资源 /errors/mws.amazonservices.com/500.html。 )
这是我的 PHP 代码。
function amazon_CreateInboundShipmentPlan($amazonAWSAccessKeyId,$amazonSellerId,$amazonMWSAuthToken,$amazonMarketPlaceId,$amazonSecretKey,$domain,$extras){
$param = array();
$param['AWSAccessKeyId'] = $amazonAWSAccessKeyId;
$param['Action'] = 'CreateInboundShipmentPlan';
$param['SellerId'] = $amazonSellerId;
$param['MWSAuthToken'] = $amazonMWSAuthToken;
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\0\0\0\Z", time());
$param['Version'] = '2010-10-01';
$param = array_merge($param,$extras);
$secret = $amazonSecretKey;
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
$amazon_feed = '';
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.'.$domain.'' . "\n";
$sign .= '/FulfillmentInboundShipment/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($amazon_feed, true));
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.".$domain."/FulfillmentInboundShipment/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
echo strlen($link)."\n";
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$errors=curl_error($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
return $array;
}
我认为 URL 长度有问题。请帮我弄清楚这段代码到底出了什么问题。
终于找到问题了。这是一个 url 限制问题 我将发布数据的方法从 GET 更改为 POST 并解决了问题。