2014-10-03 227 views
1

我想从亚马逊Web服务调用GetAuthToken:亚马逊GetAuthToken C#

http://docs.developer.amazonservices.com/en_US/auth_token/AuthToken_GetAuthToken.html

我检查了C#客户端库,我找不到GetAuthToken的方法。这是否已经实施?我试图做一个没有库的POST请求,它失败了。这是我的请求和响应,我手动写道:

请求

POST https://mws.amazonservices.com/ HTTP/1.1 
Content-Type: application/x-www-form-urlencoded 
Host: mws.amazonservices.com 
Content-Length: 238 
Expect: 100-continue 
Connection: Keep-Alive 

AWSAccessKeyId=XX&Action=GetAuthToken&SellerId=XX&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2014-09-01T16%3A41%3A16Z&Version=2011-07-01&Signature=vRBxMEXAMPLES2y0FGPufG4u7WY2HqhcsYUW6IVI9%2BQ%3D 

响应:

HTTP/1.1 404 Not Found 
Date: Fri, 03 Oct 2014 17:14:53 GMT 
Server: AmazonMWS 
x-mws-request-id: 1a0bd189-d3e9-40b8-a55d-a420c9ed4805 
x-mws-timestamp: 2014-10-03T17:14:54.195Z 
x-mws-response-context: VaGpX6JmTb+cM7WqwM6Fs8/E4oExbxl5c7li/EU0ho2j0/WpcYuG1XZSQzkuyrlr+kVTKBdKeG6F 3nwhM5s2gg== 
Content-Type: text/xml 
Content-Length: 368 
Vary: User-Agent 

<?xml version="1.0"?> 
<ErrorResponse xmlns="https://mws.amazonservices.com/"> 
<Error> 
    <Type>Sender</Type> 
    <Code>InvalidAddress</Code> 
    <Message>Resource/is not found on this server. API Section is missing or you have provided an invalid operation name.</Message> 
</Error> 
<RequestID>1a0bd189-d3e9-40b8-a55d-a420c9ed4805</RequestID> 
</ErrorResponse> 

回答

1

你有错的serviceUrl设置。您不能将其作为“mws.amazonservices.com”,您必须根据商店位置指定适当的ServiceURL。使用以下设置之一(取自Amazon库样品)或查看更完整的开发人员指南:

// North America: 
$serviceUrl = "https://mws.amazonservices.com/Products/2011-10-01"; 

// Europe 
$serviceUrl = "https://mws-eu.amazonservices.com/Products/2011-10-01"; 

// Japan 
$serviceUrl = "https://mws.amazonservices.jp/Products/2011-10-01"; 

// China 
$serviceUrl = "https://mws.amazonservices.com.cn/Products/2011-10-01";