Tips¶
Send SMS with account sid and auth token¶
from twilio.rest import Client
account_sid = "SK***"
auth_token="***"
client = Client(username=account_sid, password=auth_token)
message = client.messages.create(body='Sample sms',from_='+1234',to='+156789',)
https://www.twilio.com/docs/messaging/tutorials/how-to-send-sms-messages/python
Send SMS with API Key and API Secret¶
from twilio.rest import Client
api_sid = "SK***"
api_secret="***"
# @note: The `account_sid`: Account SID, required if using api_key to authenticate
account_sid="AC***"
client = Client(username=api_sid, password=api_secret, account_sid=account_sid)
# By using from number
message = client.messages.create(body='Sample sms',from_='+1234',to='+156789',)
# By using messaging service sid
message = client.messages.create(body='Sample sms',messaging_service_sid=messaging_service_sid, to='+156789',)
Send SMS by using messaging service sid¶
# By using from number
message = client.messages.create(body='Sample sms',from_='+1234',to='+156789',)
# By using messaging service sid
message = client.messages.create(body='Sample sms',messaging_service_sid=messaging_service_sid, to='+156789',)