I followed @KansasCityWX for several months until late in March, 2016 when it stopped posting usable entries altogether. @KansasCityWX afforded me a nice heads up on the current temperature, but ended up being limited since that was all that it reported on, just the temperature for the next 6 hours.
While it was usable, the limitations inspired me to write up my own script. Due to the 140 character limitations of the Twitter platform, it needs to be succinct, and have actionable information in three or so lines. Chewed on it, and came up with a rough layout of the data...
|Temperature Now||Temperature Later|
|Today's Overall Forecast|
The first bit was to hunt down some free weather API to query. I run across the The Dark Sky Forecast API and was immediately hooked. Well documented, well laid out API. Calls were easily made in Python.
They do manage to dump a really large tub of data on you, so there was a bit of hacking involved just to grab the bare essentials to get posted. But, it's worth it. And it's free as long as you make less than 1,000 API calls a day. Seeing that @KCWeatherBot has a planned duty cycle of 4 calls a day, this one was a no-brainer.
Twitter and Python
Arguably the most difficult part was trying to pick out a Python library for the project. Ended up with the simple Twitter api. Installs with a simple
pip install twitter and you're off to the races.
The other component to the Twitter difficulty was puzzling through their Application Management console and creating all of the relevant keys to my app could talk to Twitter. The console was okay, but then there was the matter of figuring out what key goes to what interface.
What made it hard? Well, then. Glad you asked.
|What Twitter's Site Calls It||What Twitter's Python Library Calls It|
|Consumer Key (API Key)||
|Consumer Secret (API Secret)||
|Access Token Secret||
So, there was a bit of me plugging the incorrect things into the incorrect slots for a while. But, I eventually pinned down the correct range of projectile voodoo necessary to breathe life into the poor beastie, eventually.
Where's The Code?
Well, it's not released at the moment, pending further testing, debugging, and cleanup. It's all pretty raw at the moment. Hit me up at @idlegiles if you're feeling especially crafty and want to check out the production code. Otherwise, I'll probably mess with it over the next month or so and post it on Github once I'm happy.