簡體   English   中英

此Amazon Product Advertising API查詢有什么問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM