Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa23485

Browse files
Merge pull request #65 from YourFriendlyError/sms
Sending SMS
2 parents 315ce88 + 1078c3a commit fa23485

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

‎SendSMS/README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Send SMS with Twilio
2+
Simple sms sender using Twilio python module.
3+
4+
# Python requirements
5+
Python 3.6 or newer
6+
7+
8+
## Installation
9+
10+
Use pip to install the necessary package(s).
11+
12+
```bash
13+
pip install -r requirements.txt
14+
```

‎SendSMS/requirements.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
twilio

‎SendSMS/sms.py‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /