使用 Python SDK 通过 client.notify.services() 创建通知服务时出现 AttributeError [英] AttributeError when creating Notify service via client.notify.services() using the Python SDK

查看:23
本文介绍了使用 Python SDK 通过 client.notify.services() 创建通知服务时出现 AttributeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Twilio(Python SDK,v 6.4.3)中为 SMS 相关的通知服务创建绑定,但它一直给我一个 AttriuteError.代码很简单:

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)

错误是:

AttributeError: 'Client' 对象没有属性 'notify'

AttributeError: 'Client' object has no attribute 'notify'

尝试 service = client.notifications.v1.services(SERV_SID) 给了我

AttributeError: 'NotificationList' 对象没有属性 'v1'

AttributeError: 'NotificationList' object has no attribute 'v1'

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

Notify 目前提供公开测试版,因此它仅受帮助程序库的 alpha 版本支持.您需要安装 alpha Python 库,比如:

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

然后你可以使用client.notify.services(SERV_SID).

这篇关于使用 Python SDK 通过 client.notify.services() 创建通知服务时出现 AttributeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆