我正在尝试在Sandbox模式下向Paypal发出api请求,但是收到了一个urlopen SSL错误。
api_url = 'https://api-3t.sandbox.paypal.com/nvp'
data =
{'CANCELURL': 'http://localhost:8000/paypal/canceled/',
'L_PAYMENTREQUEST_0_AMT0': '2749.00',
'L_PAYMENTREQUEST_0_DESC0': 'Like Christmas in a cup',
'L_PAYMENTREQUEST_0_NAME0': 'Apple ',
'L_PAYMENTREQUEST_0_QTY0': '1',
'METHOD': 'SetExpressCheckout',
'PAYMENTREQUEST_0_AMT': '2749.00',
'PAYMENTREQUEST_0_CURRENCYCODE': 'USD',
'PAYMENTREQUEST_0_DESC': 'Your payment to Foobar Inc.',
'PAYMENTREQUEST_0_ITEMAMT': '2749.00',
'PAYMENTREQUEST_0_PAYMENTACTION': 'Sale',
'PWD': '****',
'RETURNURL': 'http://localhost:8000/paypal/confirm/',
'SIGNATURE': '****',
'USER': '****',
'VERSION': '91.0'}
response = urllib2.urlopen(api_url, data=urlencode(data))
我得到的回应是
回溯(最近一次呼叫最后一次):文件"",第1行,in 文件 " /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py" ;, 第154行,在urlopen中 return opener.open(url,data,timeout)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 第431行,公开 response = self._open(req,data)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 第449行,在_open ' _open',req)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 第409行,在_call_chain中 result = func(* args)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 第1240行,在https_open中 context = self._context)File" /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", 第1197行,在do_open中 提出URLError(错误)URLError:
是因为我从非https客户端(localhost)发送请求吗?几个月前我试过这个工作正常。我有什么设置要改变吗?这是API最近的变化吗?