我正在尝试使用 httplib 将信用卡信息发送到 authorize.net。当我尝试发布请求时,我得到以下回溯:
File "./lib/cgi_app.py", line 139, in run res = method()
File "/var/www/html/index.py", line 113, in ProcessRegistration conn.request("POST", "/gateway/transact.dll", mystring, headers)
File "/usr/local/lib/python2.7/httplib.py", line 946, in request self._send_request(method, url, body, headers)
File "/usr/local/lib/python2.7/httplib.py", line 987, in _send_request self.endheaders(body)
File "/usr/local/lib/python2.7/httplib.py", line 940, in endheaders self._send_output(message_body)
File "/usr/local/lib/python2.7/httplib.py", line 803, in _send_output self.send(msg)
File "/usr/local/lib/python2.7/httplib.py", line 755, in send self.connect()
File "/usr/local/lib/python2.7/httplib.py", line 1152, in connect self.timeout, self.source_address)
File "/usr/local/lib/python2.7/socket.py", line 567, in create_connection raise error, msg
gaierror: [Errno -2] Name or service not known
我像这样构建我的请求:
mystring = urllib.urlencode(cardHash)
headers = {"Content-Type": "text/xml", "Content-Length": str(len(mystring))}
conn = httplib.HTTPSConnection("secure.authorize.net:443", source_address=("myurl.com", 443))
conn.request("POST", "/gateway/transact.dll", mystring, headers)
要为此添加另一层,它正在我们的开发服务器上工作,该服务器具有 httplib 2.6,并且在 httplib.HTTPSConnection 中没有 source_address 参数。
任何帮助是极大的赞赏。
==================================================== =========
编辑:
我可以从命令行运行它。显然这是某种权限问题。任何想法我需要向哪些用户授予什么权限才能做到这一点?可能Apache无法打开端口?