问题描述
import os
from twilio.rest import Client
account_sid = 'my_account_sid'
auth_token = 'my_auth_token'
client = Client(account_sid,auth_token)
def send_sms(user_code,phone_number):
message = client.messages.create(
body= f'Hi your verification code is {user_code}',from_ = '+14158557747',to = f'{phone_number}')
# phone_number 采用国际格式,类似于 +9779845000001
我在运行服务器时收到以下错误日志..
Request Method: GET
Request URL: http://127.0.0.1:8000/verify/
Django Version: 3.1.6
Exception Type: TwilioRestException
Exception Value:
[31m[49mHTTP Error[0m [37m[49mYour request was:[0m
[36m[49mPOST /Accounts/AC3c6c0502535317b9bb95efd43c6296d1/Messages.json[0m
[37m[49mTwilio returned the following information:[0m
[34m[49mUnable to create record: Authenticate[0m
[37m[49mMore information may be available here:[0m
[34m[49mhttps://www.twilio.com/docs/errors/20003[0m
任何帮助都值得赞赏。
解决方法
只需从 Twilio 控制台查看并输入帐户 Sid。复制并粘贴此帐户 sid 会更改。您可以复制和粘贴令牌。 如果是跟踪帐户,请确保验证“to”号码。