Python 将POST从请求转换为GAE urlfetch

Python 将POST从请求转换为GAE urlfetch,python,multithreading,google-app-engine,python-requests,Python,Multithreading,Google App Engine,Python Requests,我正在用贝宝付款。以下是它如何正确处理请求: res = requests.post(get_payment_info_url, headers=headers, data=params) res_data = res.json() 但是,当我尝试使用urlfetch执行相同的请求时,它给了我一个错误(PayPal提供了200个响应,但支付失败): 看来谷歌是在剥离标题还是什么?如果谷歌这样做了,我该如何提出这个请求 最后,是否有任何理由在请求上使用urlfetch(我已在本地将其导入到我的G

我正在用贝宝付款。以下是它如何正确处理
请求

res = requests.post(get_payment_info_url, headers=headers, data=params)
res_data = res.json()
但是,当我尝试使用
urlfetch
执行相同的请求时,它给了我一个错误(PayPal提供了200个响应,但支付失败):

看来谷歌是在剥离标题还是什么?如果谷歌这样做了,我该如何提出这个请求


最后,是否有任何理由在
请求上使用
urlfetch
(我已在本地将其导入到我的GAE项目中?请求似乎更容易使用且“友好”。

为此,需要对负载进行urlencoded。以下是有效的方法:

res2 = urlfetch.fetch(
                 url,
                 headers=headers,
                 method='POST',
                 payload=urllib.urlencode(params)
               )
res2_data = json.loads(res2.content)
看一看我如何轻松地修补这个库以使用GAE,如下所述:

请求适用于GAE,但仅适用于版本2.3.0(!)

在Google Appengine(1.9.17版)上,如果启用了计费功能,则2.3.0版(仅!)可在生产中运行(但不在SDK上),从而启用套接字支持

Appengine SDK上的请求因所有https://请求而失败:

  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
请求版本2.4.1失败,原因是:

  File "distlib/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
  File "distlib/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
请求版本2.5.1失败,原因是:

  File "distlib/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))
  File "distlib/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
  ConnectionError: ('Connection aborted.', error(13, 'Permission denied'))

有关套接字支持的信息:

谢谢您!