问题
I'm trying to create a binding for an SMS-related notify service in Twilio (Python SDK, v 6.4.3), but it keeps giving me an AttriuteError
. The code is simply:
from twilio.rest import Client
from myproj.twilio_settings import ACCNT_SID, AT, SERV_SID
client = Client(ACCNT_SID, AT)
service = client.notify.services(SERV_SID)
def bind_user_to_twilio_notify_service(user_id,phone_number):
binding = service.bindings.create(
identity=user_id,
binding_type='sms',
address=phone_number,
)
print(binding.sid)
And the error is:
AttributeError: 'Client' object has no attribute 'notify'
Trying service = client.notifications.v1.services(SERV_SID)
gives me
AttributeError: 'NotificationList' object has no attribute 'v1'
回答1:
Twilio developer evangelist here.
Notify is currently available in public beta and as such it is supported only by the alpha version of helper libraries. You'll need to install the alpha Python library, like:
pip install twilio==6.4.3a1
then you can use client.notify.services(SERV_SID)
.
来源:https://stackoverflow.com/questions/45081365/attributeerror-when-creating-notify-service-via-client-notify-services-using-t