我正在尝试通过 PHP 的 Curl 库向亚马逊卖家 API 的 ListOrders 函数发送请求。我可以连接,但我从他们的服务中收到 AccessDenied 错误。文档说这意味着我试图在没有 HTTPS 的情况下进行连接,但我连接的 url 是https://mws.amazonservices.com/
这是我的卷曲请求
private function send_request()
{
$string = '';
$count = 0;
foreach ($this->options as $k => $v)
{
$string .= rawurlencode($k) . "=" . rawurlencode($v);
$string .= ($count == count($this->options) -1)? '': "&";
$count++;
}
$options = array(
CURLOPT_CAINFO=> <<Cert location>>,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_POST=>true,
CURLOPT_PORT=>443,
CURLOPT_POSTFIELDS=> $string,
CURLOPT_SSL_VERIFYHOST=>2,
CURLOPT_SSL_VERIFYPEER=> TRUE,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_VERBOSE => 1,
CURLOPT_HEADER=>true,
CURLOPT_PROTOCOLS=> CURLPROTO_HTTPS,
CURLINFO_HEADER_OUT=>true
);
$session = curl_init($this->url);
curl_setopt_array($session, $options);
$results = curl_exec($session);
$errors = curl_error($session);
$info = curl_getinfo($session);
curl_close($session);
echo htmlentities($results);//var_dump($errors);
echo "<br /><br />";
print_r($info);
return $results;
}
我得到的错误是:
<?xml version="1.0"?> <ErrorResponse xmlns="https://mws.amazonservices.com/Orders/2011-01-01">
<Error>
<Type>Sender</Type>
<Code>AccessDenied</Code>
<Message>Access to Orders.ListOrders is denied</Message>
</Error>
<RequestID>4e60baef-b2a4-44aa-a18f-dd6fe8b07cf5</RequestID> </ErrorResponse>
我的卷曲信息打印输出是:
Array
(
[url] => https://mws.amazonservices.com/Orders/2012-11-27
[content_type] => text/xml
[http_code] => 401
[header_size] => 362
[request_size] => 494
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 1.42
[namelookup_time] => 0.016
[connect_time] => 0.078
[pretransfer_time] => 1.342
[size_upload] => 345
[size_download] => 310
[speed_download] => 218
[speed_upload] => 242
[download_content_length] => 310
[upload_content_length] => 345
[starttransfer_time] => 1.42
[redirect_time] => 0
[certinfo] => Array
(
)
我的数据针对请求的格式正确(签名有效等)。这个问题是我从非 SSL 保护站点发出此请求的结果(即使我正在连接到他们的 https 站点),还是我还缺少其他东西?
谢谢您的帮助。