django查看urllib2.py https错误twilio api
我正在使用 Twilio api 发送短信,但收到以下错误:
“未知的 url 类型:https”
我已经使用 Openssl 重新编译了 python,因此我的代码在 python 解释器中运行良好,但每当我尝试在我的 django 视图之一中运行它,我收到此错误。这是我的代码:
def send_sms(request):
recipient = '1234567890'
account = twilio.Account(settings.TWILIO_ID, settings.TWILIO_TOKEN)
params = { 'From': settings.TWILIO_NUM, 'To': recipient, 'Body': 'This is a test message.', }
account.request('/%s/Accounts/%s/SMS/Messages' % (settings.TWILIO_API_VERSION, settings.TWILIO_ID), 'POST', params)
编辑-更多信息(感谢您提出 Stefan) 该项目通过 Passenger wsgi 托管在 dreamhost 上。 Django 使用相同的 python 安装位置和 interp。
我很感激任何人可能有的见解,谢谢!
I'm looking to send an SMS with the Twilio api, but I'm getting the following error:
"unknown url type: https"
I've recompiled python with Openssl, so my code runs fine from the python interpretor, but whenever I try to run it in one of my django views I get this error. Here is my code from my view:
def send_sms(request):
recipient = '1234567890'
account = twilio.Account(settings.TWILIO_ID, settings.TWILIO_TOKEN)
params = { 'From': settings.TWILIO_NUM, 'To': recipient, 'Body': 'This is a test message.', }
account.request('/%s/Accounts/%s/SMS/Messages' % (settings.TWILIO_API_VERSION, settings.TWILIO_ID), 'POST', params)
Edit- More info (thanks for bringing that up Stefan)
The project is hosted on dreamhost via Passenger wsgi. Django is using the same python install location and interp.
I appreciate any insight anyone may have, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这只是用户错误。我的 wsgi 文件使用了不同的解释器,但路径非常相似,我只是忽略了它。一旦我修复了 django 使用的是我用 openssl 编译的 python 版本,一切工作正常。
拆开电视之前,请务必检查电视是否已插入电源。谢谢斯特凡!
Looks like it was just user error. My wsgi file was using a different interpreter but the paths were so similar I was just over looking it. Once I fixed that django was using the python version that I compiled with openssl and everything worked fine.
Always check if the tv is plugged in before you take it apart. Thanks stefanw!