SMS Rain Alert

import requests, import os
from twilio.rest import Client
from twilio.http.http_client import TwilioHttpClient
endpoint = "https://api.openweathermap.org/data/2.5/onecall"
api_key = "YOUR OWN API KEY GOES HERE"

latitude = "YOUR LATITUDE"
longitude = "YOUR LONGITUDE"
account_sid = "YOUR ACCOUNT SID GOES HERE"
auth_token = "YOUR AUTHENTICATION TOKEN GOES HERE"
twilio_number = "+YOUR TWILIO NUMBERS GOES HERE"

weather_parameters = {
"lat": latitude,
"lon": longitude,
"appid": api_key,
"exclude": "current,minutely,daily",
}
response = requests.get(endpoint, params=weather_parameters)
response.raise_for_status()
weather_data = response.json()
weather_slice = weather_data["hourly"][:12]
may_rain = False
for hour_data in weather_slice:
condition_code = hour_data["weather"][0]["id"]
cc = condition_code
if int(cc) < 700:
may_rain = True
if may_rain:
proxy_client = TwilioHttpClient(proxy={'http': os.environ['http_proxy'], 'https': os.environ['https_proxy']})
client = Client(account_sid, auth_token, http_client=proxy_client)
message = client.messages \
.create(
body='β˜‚οΈShalom, you may want to bring an umbrella with you!β˜‚οΈ',
from_='+12072808637',
to="+15106730075"
)
print(message.status)

print(f"🌑πŸ”₯\n{weather_data}\nπŸ”₯🌑")
print(f"🌑πŸ”₯\n{weather_slice}\nπŸ”₯🌑")