我已经在这方面工作了几天而且我在这一点上有点失落,希望能有一点帮助来克服这个减速带。我是编程和python的新手,但我已经为Amazons Product api创建了一些请求,并认为SubmitFeed不同。我在MWS便笺簿中运行相同的设置,然后获得与我的代码创建的不同的签名。我不确定我做错了什么,我已经多次检查过有效载荷,没有任何东西可以脱颖而出。任何帮助都会很棒。
def get_data():
global SECRET_KEY
request_description = '&'.join(['%s=%s' % (k, urllib.parse.quote(payload[k], safe='-_.~')) for k in sorted(payload)])
#print(request_description)
sig_data = method + "\n" + domain.replace('https://', '').lower() + "\n" + URI + "\n" + request_description
sig_data = bytes(sig_data, 'utf-8')
SECRET_KEY1 = bytes(SECRET_KEY, 'utf-8')
sig_data = hmac.new(SECRET_KEY1, sig_data, digestmod=hashlib.sha256)
print(sig_data.hexdigest())
calc_signature = urllib.parse.quote(base64.b64encode(sig_data.digest()), safe='-_.~')
sig = calc_signature
print(sig)
url = '%s%s?%s&Signature=%s' % (domain, URI, request_description, sig)
r = requests.post(url)
file = open('C:\Python34\Python34\CompetitorsPrices.xml', 'w+')
print(r.text, end="", file=file)
file.close()
SECRET_KEY = '**'
AWS_ACCESS_KEY = '**'
SELLER_ID = '**'
MARKETPLACE_ID = '**'
Action = 'SubmitFeed'
SignatureMethod = 'HmacSHA256'
SignatureVersion = '2'
Timestamp = '2017-02-17T18:51:08Z'
Version = '2009-01-01'
URI = '/'
domain = 'https://mws.amazonservices.com'
method = 'POST'
payload = {'AWSAccessKeyId': AWS_ACCESS_KEY,
'Action': Action,
'Merchant': SELLER_ID,
'SignatureVersion': SignatureVersion,
'Timestamp': Timestamp,
'Version': Version,
'SignatureMethod': SignatureMethod,
'MarketplaceIdList.Id.1': MARKETPLACE_ID,
'FeedType': '_POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA_',
'PurgeAndReplace': 'false'}
get_data()
print('Press Enter to Exit')