我正在使用 PayPal 付款。这是它如何正确工作的requests
:
res = requests.post(get_payment_info_url, headers=headers, data=params)
res_data = res.json()
但是当我尝试对以下内容执行相同的请求时urlfetch
,它给了我一个错误(PayPal 的 200 响应,但付款失败):
res = urlfetch.fetch(url=make_payment_url, payload=params, method=urlfetch.POST, headers=headers)
res_data = json.loads(res)
{u'responseEnvelope': {u'timestamp': u'2015-02-15T23:21:52.729-08:00', u'ack': u'Failure', u'build': u'15089777', u'correlationId': u'e202988541fde'},
u'error': [{u'domain': u'PLATFORM', u'message': u'Invalid request: {0}', u'severity': u'Error', u'subdomain':
u'Application', u'category': u'Application', u'errorId': u'580001'}]}
看来谷歌可能正在剥离标题之类的?如果 Google 这样做,我将如何提出此请求?
最后,有什么理由使用urlfetch
over requests
(我已将其本地导入到我的 GAE 项目中?Requests 似乎使用起来更加容易和“友好”。