Weather SMS Notifier This Python script allows you to retrieve the current temperature of a specified city and send it as an SMS using the Twilio API. It uses the OpenWeatherMap API to fetch weather data.
Before you can use this script, you need to set up the following:
You need to have a Twilio account. If you don't have one, you can sign up at Twilio.
Replace the placeholders in the script with your actual Twilio Account SID and Auth Token. You can find these credentials in your Twilio dashboard.
: Replace twilio_phone_number with your Twilio phone number. This is the phone number that will be used to send the SMS.
Replace recipient_phone_number with the recipient's phone number. This is where the SMS with the temperature will be sent.
You need to sign up for an OpenWeatherMap API key at OpenWeatherMap and replace the api_key in the script.
Make sure you have the required Python libraries installed. You can install them using pip:
pip install requests twilio fake-useragent
Run the script by executing it in your terminal or IDE:
python weather_sms_notifier.py Enter the name of the city for which you want to retrieve the temperature when prompted.
The script will make an API call to OpenWeatherMap, fetch the temperature data, and send an SMS to the specified recipient with the temperature information.
You will see a confirmation message in the terminal.
This script uses a random User-Agent string generated by the fake-useragent library to simulate a web browser. If you want to customize the User-Agent, you can modify the user_agent_string variable in the script.
Error Handling The script includes error handling to handle potential issues with API requests. If there are any errors, they will be displayed in the terminal.
Note Make sure you are aware of the Twilio API usage costs, as sending SMS messages may incur charges.
The OpenWeatherMap API has rate limits for free accounts. Be mindful of these limits if you plan to use this script frequently.
Feel free to modify this README as needed to provide additional information or instructions specific to your use case.