简体   繁体   English

Amazon MWS:ListOrders的访问被拒绝错误

[英]Amazon MWS : Access denied Error for ListOrders

Yesterday my code was working and today when I again check it is throwing an error. 昨天我的代码在工作,今天再次检查它在抛出错误。 I want to fetch the orders from amazon India for which I have used Orders.ListOrders API of Amazon MWS here is my code : 我想从我使用Amazon MWS的Orders.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;

Response : 回应:

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

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

  2. It was working yesterday and today it is showing error why ? 昨天工作,今天却显示错误,为什么?

  3. What should I do to make this work again ? 我该怎么做才能再次进行这项工作?

  4. It is working on Amazon scratchpad 它正在亚马逊暂存器上工作

Please help me on this. 请帮我。 Thanks in advance. 提前致谢。

Just put this curl option after curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 只需将此curl选项放在curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); and try again : 然后再试一次 :

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM