Skip to content

tirth1305/Temprature-API-Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Temprature-API-SMS Notifier

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.

Prerequisites

Before you can use this script, you need to set up the following:

Twilio Account

You need to have a Twilio account. If you don't have one, you can sign up at Twilio.

Twilio Credentials

Replace the placeholders in the script with your actual Twilio Account SID and Auth Token. You can find these credentials in your Twilio dashboard.

Twilio Phone Number

: Replace twilio_phone_number with your Twilio phone number. This is the phone number that will be used to send the SMS.

Recipient Phone Number:

Replace recipient_phone_number with the recipient's phone number. This is where the SMS with the temperature will be sent.

OpenWeatherMap API Key:

You need to sign up for an OpenWeatherMap API key at OpenWeatherMap and replace the api_key in the script.

Python Libraries:

Make sure you have the required Python libraries installed. You can install them using pip:

Copy code

pip install requests twilio fake-useragent

Usage

Run the script by executing it in your terminal or IDE:

Copy code

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.

Customize User-Agent

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages