如何使用 urllib2 通过 https 发布数据?
我想使用 Paybox.com API 在我的网站中集成信用卡处理。
当用户提交表单时,我必须向 Paybox API 发送带有信用卡详细信息(号码、日期、CVV)的 POST 请求(使用 urllib2)。
我怎样才能确保这一点?将 https://www.mywebsite.com/card/processing 放入我的表单中是否足够行动?
如何使用 urllib2 通过 HTTPS 发送 POST 数据?
PS:我从事 Django 工作。
I want to integrate a credit card processing in my website using Paybox.com API's.
I have to send a POST request (using urllib2) to Paybox API's with credit card details (number, date, cvv) when a user submit a form.
How can I secure that? is it enougth to put https://www.mywebsite.com/card/processing in my form action?
How can I send POST data over HTTPS using urllib2?
PS: I work on Django.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在安全性方面,请参阅此 QA:POST 数据加密 - HTTPS 足够了吗?
至于如何做到这一点,这里有一个关于使用 urllib 的解释: http://www.codercaste.com/2009/11/28/how-to-use-the-urllib-python- library-to-fetch-url-data-and-more/
思路是使用urlencode命令为请求创建一个parameters对象,然后根据url和parameters对象创建一个request对象,然后对请求对象调用 urlopen 以实际发送请求。
Well in terms of security refer to this QA: POST data encryption - Is HTTPS enough?
As far as how to do it, here's an explanation about using urllib: http://www.codercaste.com/2009/11/28/how-to-use-the-urllib-python-library-to-fetch-url-data-and-more/
The idea is to use the urlencode command to create a parameters object for the request, then create a request object from the url and the parameters object, and then call urlopen on the request object in order to actually send the request.
以下是使用 python-request lib 的解决方案:http: //www.python-requests.org/en/latest/user/advanced/
顺便说一下,python-request是一种非常强大且简单的提出请求的方法。
Here are solutions using python-request lib: http://www.python-requests.org/en/latest/user/advanced/
By the way, python-request is a very powerful and easy way to make requests.