在Google应用引擎上运行基本的Twilio API
我尝试在谷歌应用引擎上运行下面的代码。虽然我通过pip安装了twilio(版本:3.6),但是我却收到一个错误提示,说找不到twilio这个模块。这是为什么呢?我该怎么解决这个问题呢?
import webapp2
from twilio import twiml
from twilio.rest import TwilioRestClient
class SendSMS(webapp2.RequestHandler):
def get(self):
account_sid = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6bc"
auth_token = "xxxxx24f327xxxxxxxxxxxxxxxxxxxxx"
client = TwilioRestClient(account_sid, auth_token)
rv = client.sms.messages.create(to="91xxxxxxxxx",
from_="+1xxxxxxxxxxx",
body="Hello Monkey!")
self.response.write(str(rv))
app = webapp2.WSGIApplication([('/send_sms', SendSMS)],
debug=True)
我遇到的错误:
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "C:\Users\TOSHIBA pc\Documents\apps\main\main.py", line 2, in <module>
from twilio import twiml
ImportError: No module named twilio
INFO 2014-07-08 14:40:35,552 module.py:639] default: "GET / HTTP/1.1" 500 -
1 个回答
1
在Google应用引擎上使用Twillio有点复杂。关于如何实现的详细信息可以在这里找到:https://twilio-python.readthedocs.org/en/latest/appengine.html