duandu9260 2014-10-02 10:55
浏览 1152
已采纳

亚马逊MWS: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 :

$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
mws.amazonservices.in
/Orders/2013-09-01
" . $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 ?

  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.

  • 写回答

1条回答 默认 最新

  • douxi4114 2014-10-02 11:13
    关注

    Just put this curl option after curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); and try again :

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win11笔记本系统出了问题
  • ¥20 找驱动QTR2774-SU-IBM版本驱动
  • ¥15 NeRF的代码复现以及人工智能入门
  • ¥15 centos如何做一个可以让ikuai连接的openvpn
  • ¥15 Protege 中的Entities下面的界面删除了如何复原
  • ¥15 scrapy爬虫求帮
  • ¥15 imageEnView绘图问题
  • ¥15 关于#python#的问题:您好可以加您一下联系方式吗,在复现的时候确实有点问题难以解决
  • ¥15 联想电脑重装系统时无法发现硬盘
  • ¥15 MATLAB与UR10e实体机械臂建立通讯