- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
Latest commit
29 lines (24 loc) · 951 Bytes
/
Copy pathtest.py
File metadata and controls
29 lines (24 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
importurllib2
importjson
fromtwilio.restimportTwilioRestClient
google_url="http://maps.googleapis.com/maps/api/geocode/json?address="
weather_url="http://api.openweathermap.org/data/2.5/weather?q="
account_sid="AC6e810f461c59369afc89d751e0a60129"
auth_token="4c12e1dd30e30177552bc9bc37a4ae59"
client=TwilioRestClient(account_sid, auth_token)
defsend_sms(zip_code, number):
response=urllib2.urlopen(google_url+str(zip_code)).read()
json_response=json.loads(response)
city_name=json_response["results"][0]["formatted_address"]
printcity_name
response2=urllib2.urlopen(weather_url+city_name.replace(' ', '%20')).read()
json_response2=json.loads(response2)
weather=json_response2["weather"][0]
weather_desc=weather["main"] +" | "+weather["description"]
printweather_desc
message=client.messages.create(
body=weather_desc,
to=number,
from_="+12407433765"
)
send_sms(20742, phone_number)