File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change 11import requests
2+ import os
3+ from twilio .rest import Client
24
3- end_point = "https://api.openweathermap.org/data/2.5/forecast"
4- api_key = "API-KEY"
5+ twilio_account_sid = os .environ ['TWILIO_ACCOUNT_SID' ]
6+ twilio_auth_token = os .environ ['TWILIO_AUTH_TOKEN' ]
7+ openweather_end_point = "https://api.openweathermap.org/data/2.5/forecast"
8+ openweather_api_key = os .environ ['OPEN_WEATHER_AUTH_TOKEN' ]
59
610weather_params = {
7- "lat" : 40.416775 ,
8- "lon" : - 3.703790 ,
9- "appid" : api_key ,
11+ "lat" : 37.270969 ,
12+ "lon" : - 79.941429 ,
13+ "appid" : openweather_api_key ,
1014 "cnt" : 4
1115}
1216
13- r = requests .get (end_point , params = weather_params )
17+ r = requests .get (openweather_end_point , params = weather_params )
1418r .raise_for_status ()
1519weather_data = r .json ()
1620
1721id_weather_list = weather_ids = [x ["weather" ][0 ]["id" ] for x in weather_data ["list" ] if x ["weather" ][0 ]["id" ] < 700 ]
1822
1923if len (id_weather_list ) >= 1 :
20- print ("Bring an umbrella" )
24+ client = Client (twilio_account_sid , twilio_auth_token )
25+
26+ message = client .messages \
27+ .create (
28+ body = "It's going to rain today! Remember to bring an ☔." ,
29+ from_ = '+twilio-phone' ,
30+ to = '+my-verified-phone'
31+ )
32+ print (message .sid )
You can’t perform that action at this time.
0 commit comments