我正在尝试使用getmatchingproductforid操作从amazon mws api获取数据。
当我使用amazon mws scratchpad时,它工作得非常好。
我现在正试图复制在http post请求中发送的url,但是我得到了一个签名错误消息。
我需要了解url请求的结构。
下面是amazon mws scratchpad中请求的详细信息,我匿名了私有标识符,但这是我唯一更改的地方:
http帖子

POST /Products/2011-10-01?AWSAccessKeyId=ANONYMIZED
&Action=GetMatchingProductForId
&SellerId=ANONYMIZED
&SignatureVersion=2
&Timestamp=2018-09-28T05%3A45%3A43Z
&Version=2011-10-01
&Signature=ANONYMIZED
&SignatureMethod=HmacSHA256
&MarketplaceId=A13V1IB3VIYZZH
&IdType=EAN
&IdList.Id.1=9781933988665 HTTP/1.1
Host: mws.amazonservices.fr
x-amazon-user-agent: AmazonJavascriptScratchpad/1.0 (Language=Javascript)
Content-Type: text/xml

要签名的字符串
POST
mws.amazonservices.fr
/Products/2011-10-01
AWSAccessKeyId=ANONYMIZED&Action=GetMatchingProductForId&IdList.Id.1=9781933988665&IdType=EAN&MarketplaceId=A13V1IB3VIYZZH&SellerId=ANONYMIZED&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2018-09-28T05%3A45%3A43Z&Version=2011-10-01

=======
现在我的问题是(假设我的签名是正确创建的),从http post中,请求应该是什么样子的?
以下是我的尝试:
https://mws.amazonservices.fr/Products/2011-10-01?AWSAccessKeyId=ANONYMIZED&Action=GetMatchingProductForId&SellerId=ANONYMIZED&SignatureVersion=2&Timestamp=2018-09-28T05%3A52%3A33Z&Version=2011-10-01&Signature=ANONYMIZED&SignatureMethod=HmacSHA256&MarketplaceId=A13V1IB3VIYZZH&IdType=EAN&IdList.Id.1=9781933988665

但是,scratchpad中的“\n”转义字符呢?最后'HTTP/1.1'怎么办,我应该也包括它吗?
谢谢你的帮助。

最佳答案

我没有MWS帐户,因此无法测试以下内容,但这是一种方法:

# set this to your python2 binary; you'll need to do
#   pip2 install boto
# from a command-line before using this code
Sys.setenv("RETICULATE_PYTHON"="/usr/bin/python2.7")

library(reticulate)

boto_mws_connection <- import("boto.mws.connection")

con <- boto_mws_connection$MWSConnection(
  aws_access_key_id = ACCESS_KEY
  aws_secret_access_key = AWS_SECRET
  Merchant = MERCHANT_ID
)

con$get_matching_product_for_id(
  MarketplaceId = "A13V1IB3VIYZZH",
  IdType = "EAN",
  IdList = c("9781933988665")
)

关于r - MWS API签名与R不匹配,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52549385/

10-11 11:03