django查看urllib2.py https错误twilio api

发布于 2024-09-08 12:08:25 字数 653 浏览 3 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缪败 2024-09-15 12:08:25

看起来这只是用户错误。我的 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文