Friday, December 11, 2009

Weather Messages Done!

Sweet!  I managed to write a script that collects weather forecasts from the National Weather Service and sends them via text message (MMS actually) to my cell phone.  I realize it's been about 24 hours since I first mentioned this little project, but I really didn't get started until about 9:00 last night, then slept and started on it again late this morning.

The only difficulties I ran into was with the raw XML data from the National Weather Service.  When I started last night, it listed minimum temperatures (the low) first, then in the next section it listed the high temps.  No big deal, I just grab them in order, insert the lows into the database, then the highs, and I'm good to go. Right?

Fat chance.  This morning I started working on it again and the first thing I noticed is that that low temps are about 20 degrees higher than they should be, so I look, and my low temps are in the high databases and the high temps are in the low database.  I ended up having to write a whole new routine to first figure out which temperatures I was dealing with before inserting them into the database.  I got it figured out, though, and it really wasn't difficult but was annoying because I had to take a few steps backwards.

I also ended up sending the messages via MMS rather than SMS to get around the 140 character limit Verizon places on you.  I understand why they set it at 140 characters, because of the extra stuff they add in, but I wanted to send the full forecast for both today and tomorrow so MMS it was.  I don't get charged for either, so it's not a big deal, really.

But at least it's done, and it works much better than I expected it to.  So I'm a very happy girl right now :)

No comments:

Post a Comment