|
| 1 | +from twilio.rest import Client |
| 2 | + |
| 3 | +sid = 'ACCOUNT SID goes here' |
| 4 | +auth_token = 'AUTH token here' |
| 5 | + |
| 6 | +twilio_number = 'Your Twilio provided number here' |
| 7 | + |
| 8 | +client = Client(sid, auth_token) |
| 9 | + |
| 10 | +details = {'Message created': '', 'Date sent': '', 'Body': ''} |
| 11 | + |
| 12 | + |
| 13 | +def craft(msg, fromPhone, sendTo): |
| 14 | + message = client.messages.create( |
| 15 | + body=msg, |
| 16 | + from_=fromPhone, |
| 17 | + to=sendTo |
| 18 | + ) |
| 19 | + |
| 20 | + details['Message created'] = str(message.date_created) |
| 21 | + details['Date sent'] = str(message.date_sent) |
| 22 | + details['Body'] = str(message.body) |
| 23 | + |
| 24 | + |
| 25 | +def main(msg: str): |
| 26 | + return craft(msg, twilio_number, '+15555550100') |
| 27 | + |
| 28 | + |
| 29 | +if __name__ == '__main__': |
| 30 | + main('Hello, user! Sent from Python!') |
| 31 | + seeDetails = input('See details of this message? [y/n]: ') |
| 32 | + if seeDetails.lower() == 'y': |
| 33 | + for i in details: |
| 34 | + print(f'{i} = {details[i]}') |
| 35 | + else: |
| 36 | + exit() |
0 commit comments