AttributeError when creating Notify service via client.notify.services() using the Python SDK

不羁的心 提交于 2019-12-11 03:53:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!