我正在使用Amazon MWS CreateInboundShipmentPlan创建发货计划,如果我将产品限制在23-24以下,则它的效果很好,但是如果我尝试提交的数量超过24,则会出现InvalidAddress错误。 我正在使用PHP API向Amazon MWS提交请求。在最初的故障排除中,我认为这与URL长度有关,因为如果我通过添加更多SKU来增加URL长度,则会开始出现问题。
但是,如果我尝试使用更多的SKU,它会给我
[错误] =>数组 ( [类型] =>发件人 [代码] => InvalidAddress [消息] =>在此服务器上找不到资源/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长度存在一些问题。请帮助我找出这段代码到底有什么问题。
答案 0 :(得分:0)
我终于弄清楚了问题所在。这是一个网址限制问题,我将我的数据发布方法从GET更改为POST,并且解决了该问题。