TwilioRestClient已删除

时间:2018-08-16 14:04:14

标签: python twilio twilio-api

IllegalThreadStateException

此代码引发异常:

  

twilio.base.obsolete.ObsoleteException:TwilioRestClient已被执行   从此版本的库中删除。请参考当前   指导文档。

似乎在任何地方都找不到对此的引用,这在几天前成功了!

使用python 3.7和VS2017

3 个答案:

答案 0 :(得分:1)

必须正在工作。

from twilio.rest import Client
# Your Account SID from twilio.com/console
account_sid = "asfdasdfasdfasdfsadfasdfsadfa"
# Your Auth Token from twilio.com/console
auth_token  = "asfdsadfasdfasdfasdfasfas"

client = Client(account_sid, auth_token)

message = client.messages.create(
to="+asdfasdfasfd",
from_="+asfdsafdsafsaf",
body="hello mister x")

print(message.sid)

这是真正的链接

https://www.twilio.com/docs/libraries/python

答案 1 :(得分:0)

使用

从twilio.rest导入客户端 tClient =客户端(sid,令牌)

已弃用TwilioRestClient。

答案 2 :(得分:0)

这对我有用:

from twilio.rest import Client

account = "Account number for Twilio"
token = "Token for Twilio Account"

client = Client(account, token)

message = client.messages.create(to="+ReceiverPhone#", from_="+TwilioPhone#",
                             body="Text message you are sending to receiver")
#print response back from Twilio
print message