2014-10-02 115 views
0

昨天我的代碼正在工作,今天當我再次檢查它是拋出一個錯誤。我想爲我所用這裏亞馬遜MWS是我的代碼的Orders.ListOrders API從亞馬遜印度獲取訂單:Amazon MWS:ListOrders的訪問被拒絕錯誤

$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. 它正在亞馬遜暫存器

請幫我在這。提前致謝。

回答

1

只是把這個捲曲選項curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);後再試一次:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
+0

嗨@hardik索蘭奇,增加......但同樣的錯誤。我真的很生氣爲什麼發生這種事 – 2014-10-02 11:17:43

+0

@RakeshShetty它的工作在我的最後。 – 2014-10-02 11:18:52

+0

你使用了哪些數據?您是否使用我昨天提供給您的憑據來運行我的代碼? – 2014-10-02 11:21:29