亚马逊MWS:ListOrders的访问被拒绝错误

时间:2014-10-02 10:55:41

标签: php amazon-web-services amazon-mws

昨天我的代码正常运行,今天我再次检查它是否发生了错误。我想从amazon India获取订单,我使用Orders.亚马逊MWS的ListOrders API这里是我的代码:

$action = 'ListOrders';

        $params = array(
                    'AWSAccessKeyId' => $data['aws_access_key'],
                    'Action' => $action,
                    'SellerId' => $data['merchant_id'],
                    'SignatureMethod' => "HmacSHA256",
                    'SignatureVersion' => "2",
                    'Timestamp'=> gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time()),
                    'CreatedAfter'=> '2014-08-31T18:00:00Z',
                    'CreatedBefore'=> '2014-09-23T18:00:00Z',
                    'Version'=> "2013-09-01",
                    'MarketplaceId.Id.1' => $data['marketplace_id']
                );

        // Sort the URL parameters
        $url_parts = array();
        foreach(array_keys($params) as $key)
            $url_parts[] = $key . "=" . str_replace('%7E', '~', rawurlencode($params[$key]));

        sort($url_parts);

        // Construct the string to sign
        $url_string = implode("&", $url_parts);
        $string_to_sign = "GET\nmws.amazonservices.in\n/Orders/2013-09-01\n" . $url_string;

        // Sign the request
        $signature = hash_hmac("sha256", $string_to_sign, $data['aws_secret_key'], TRUE);

        // Base64 encode the signature and make it URL safe
        $signature = urlencode(base64_encode($signature));

        $url = "https://mws.amazonservices.in/Orders/2013-09-01" . '?' . $url_string . "&Signature=" . $signature;

        //echo $url;exit;

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        $response = curl_exec($ch);

        // Create DOM object and load eBay response
        $responseDoc = new DOMDocument();
        $responseDoc->loadXML($response);

        $response = simplexml_import_dom($responseDoc);

        //$parsed_xml = simplexml_load_string($response);

        //echo $url;exit;

        echo '<pre>';
        print_r($response);
        echo '</pre>';
        exit;

回应:

SimpleXMLElement Object
(
    [Error] => SimpleXMLElement Object
        (
            [Type] => Sender
            [Code] => AccessDenied
            [Message] => Access denied
        )

    [RequestID] => 890a9075-2993-4063-be60-922c43bb8428
)
  1. [Message] => Access denied错误表示什么?

  2. 它昨天工作,今天显示错误原因?

  3. 我该怎样做才能让这项工作重新开始?

  4. 它正在使用Amazon scratchpad

  5. 请帮我解决这个问题。提前谢谢。

1 个答案:

答案 0 :(得分:1)

只需在curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);之后放置此卷曲选项​​,然后重试:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);