twilio打电话和发短信

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
# @Time    : 2018/03/09 14:53
# @Author  : cxa
# @File    : call.py
# @Software: PyCharm
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import Client
 
# Your Account Sid and Auth Token can be found at https://www.twilio.com/console
account_sid = "mysid"
auth_token = "token"
client = Client(account_sid, auth_token)
 
# # Start a msg
# call = client.messages.create(
#     to="+mynumber",
#     from_="+18162811118",
#     body="短信内容"
# )
# Start a phone call
call = client.calls.create(
    to="+mynumber",
    from_="+18162811118",
    url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"
)
 
print(call.sid)

重要的一步默认没有授权中国地区的需要开启授权,

Account not authorized to call . Perhaps you need to enable some international permissions: twilio.com/user/account/settings/international


打电话的时候会一直报错

twilio.base.exceptions.TwilioRestException: HTTP 400 error: Unable to create record: The number +mynumberis unverified. Trial accounts may only make calls to verified numbers.



最后的解决方案是

Verified Caller IDs:

https://www.twilio.com/user/account/phone-numbers/verified

 

本文作者:公众号python学习开发

本文链接:https://www.cnblogs.com/c-x-a/p/8535115.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   公众号python学习开发  阅读(3597)  评论(1编辑  收藏  举报
历史上的今天:
2017-03-09 DataTables 1.10.x与1.9.x参数名对照表
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起