Created
March 12, 2020 09:20
-
-
Save minshinkhant/424525fc73cbe08c200c6277f003e853 to your computer and use it in GitHub Desktop.
Sending birthday reminder message to your phone number with Twilio trial account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sending birthday reminder message to your phone number | |
#with twilio trial account | |
import time | |
import os | |
from twilio.rest import Client | |
from twilio.http.http_client import TwilioHttpClient | |
proxy_client = TwilioHttpClient() | |
proxy_client.session.proxies = {'https': os.environ['https_proxy']} | |
account_sid = '[your_account_sid]' | |
auth_token = '[AuthToken]' | |
client = Client(account_sid, auth_token, http_client=proxy_client) | |
def checkTodayBirthdays(): | |
file_name = open('text.txt', 'r') | |
today = time.strftime('%m%d') | |
flag = 0 | |
for line in file_name: | |
if today in line: | |
line = line.split(' ') | |
flag = 1 | |
# twilio api calls will now work from behind the proxy: | |
message = client.messages.create( | |
from_='new_ph_number_we_created', | |
to='your_phone_number', | |
body=f"Today is {line[1]} {line[2]} birthday!!" | |
) | |
print(message.sid) | |
if flag == 0: | |
no_birthday = client.messages.create( | |
from_='new_ph_number_we_created', | |
to='your_phone_number', | |
body="There is no birthday Today!!!" | |
) | |
print(no_birthday.sid) | |
if __name__ == '__main__': | |
checkTodayBirthdays() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment