[英]What is wrong with this Amazon Product Advertising API query
我一直收到400 Bad Request Error
。 请任何人告诉我我在做什么错吗? 我不想使用库。
from requestmanager import RequestManager
from datetime import datetime
from urllib import quote
dt = quote(datetime.strftime(datetime.utcnow(), '%Y-%m-%d %H:%M:%S'))
sign = quote('mySecretAceessKey')
key = 'myKey'
if __name__ == '__main__':
rP = RequestManager()
url = 'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId='+key+'&Operation=ItemLookup&ItemId=B003MWJKVI&ResponseGroup=Large&Timestamp='+dt+'&Signature='+ sign
response = rP.getContent(url)
content = response.RESPONSE
我正在按照此处提到的步骤进行操作。
您的时间戳变量的格式不正确。 使用您创建的URL,将其放入浏览器中,并查看返回的xml消息。 尝试像这样创建时间戳:
import time
dt = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
在更正该HTTPError: HTTP Error 403: Forbidden
之后,我得到了HTTPError: HTTP Error 403: Forbidden
。 在浏览器中尝试该URL会告诉我(除其他内容外):
... <Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error> ...
我发现,自2009年8月17日起,亚马逊要求签署对其产品广告API的所有请求。
以下链接为创建必要的网址提供了一种非常好的方法,请检查一下: http : //www.princesspolymath.com/princess_polymath/?p=182
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.