This Python script demonstrates how to send an SMS message to a recipient using the Twilio API. Twilio is a cloud communications platform that provides an API to send text messages.
Before using this code, you need to:
-
Sign up for a Twilio account at Twilio.
-
Obtain your Twilio Account SID and Auth Token.
-
Create a Twilio phone number.
-
Install the required Python library using pip:
pip install twilio
-
Replace the following placeholders in the Python script with your own information:
'your_account_sid': Your Twilio Account SID.'your_auth_token': Your Twilio Auth Token.'+your_twilio_phone_number': Your Twilio phone number.to_phone_number: The recipient's phone number.message: The message you want to send.
-
Run the Python script. It will send an SMS message to the specified recipient.
-
The script imports the
twiliolibrary to interact with the Twilio API. -
It creates a Twilio client using your Account SID and Auth Token.
-
You provide the recipient's phone number and the message you want to send.
-
The script then sends the SMS message using the
client.messages.createmethod. -
The SID of the sent message will be printed to the console.
This project is licensed under the MIT License - see the LICENSE file for details.