我熟悉 PHP 中的 CURL,但我第一次在 Python 中使用它和 pycurl。
我不断收到错误:
Exception Type: error
Exception Value: (2, '')
我不知道这可能意味着什么。这是我的代码:
data = {'cmd': '_notify-synch',
'tx': str(request.GET.get('tx')),
'at': paypal_pdt_test
}
post = urllib.urlencode(data)
b = StringIO.StringIO()
ch = pycurl.Curl()
ch.setopt(pycurl.URL, 'https://www.sandbox.paypal.com/cgi-bin/webscr')
ch.setopt(pycurl.POST, 1)
ch.setopt(pycurl.POSTFIELDS, post)
ch.setopt(pycurl.WRITEFUNCTION, b.write)
ch.perform()
ch.close()
错误是指该行ch.setopt(pycurl.POSTFIELDS, post)