Weather "Sticker"

He has: 688 posts

Joined: Feb 2001

I've already got a descent Weather "Sticker" on my website but I need something different. The one that I use is preset via code to a particular city (US Zip Code). That worked fine before but I am expanding my target audience to an entire region... hundreds of cities. Many weather sticker services like weather.com and the one I use offer versions where a visitor can put enter his Zip Code and get personalized weather information, but that user customization doesn't persist. The visitor would need to enter their Zip Code every time they visit, and I'd prefer they just be able to glance over and see their forecast without having to do anything further. I've looked around and can't find anything that does quite what I want. (Here's a thread of somebody with a similar request from four years ago but I don't think that's what I need either.)

So since many of these sticker services use simple code that includes the zipcode in the url... I was thinking that I could store the user preference in a cookie and maybe embed that zipcode from the cookie into the code which calls for the weather sticker. Is this possible (pages are in php)? If so, I've never made a cookie nor know how to read data off of one so where would I begin? Is this a good solution? Thanks for the info.

Of course, if anybody knows of a simpler solution, please let me know.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

sounds like it's possible, but I wonder if it's against the TOS of the weather buttons? If not, post in Scripting and I'm sure we can work it out. Smiling

He has: 688 posts

Joined: Feb 2001

Well it turns out that weather.com uses an unrecognizable string in its code. The one I am using now uses city name instead of zip. But I found one that will work perfectly for me. I checked for a TOS and don't see any restrictions at all, although I will of course keep the link back to their website as this is why they are providing this free service.

Here's a code example:

<a href="http://www.addresses.com/forecast/28273.html"><img src="http://www.weatherroom.com/weather?forecast=hourly&hwvtc=000000&hwvbg=FFFFFF&pands=28273&config=png&alt=hwicc" alt="Weather for 28273 Powered by addresses.com" border="0"></a>
<br /><font size="1">Powered by <a href="http://www.addresses.com/weather.php">Addresses.com Weather </a></font>
'

Here's the image from the code above, and an altered one to a different zipcode, showing this concept of zip code altering should work fine.

Now I need a little help. Other than help with how to make a cookie that will store the zip code preference and then use it again next time.... can somebody help move this thread to the appropriate forum category, "Scripting"? Thanks.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Moving it, sir! Smiling

He has: 1,380 posts

Joined: Feb 2002

I have used it before, check the .pdf file that comes with your installation files. There is a long list of codes for the cities, and a link to where you can search a dB for a city's code (it's an xml page). You could maybe have the user put in a city, and then query this xml-interfaced dB, and return the results, inputting into a URL. See what I mean, Vern?

He has: 688 posts

Joined: Feb 2001

Eskater05 wrote: I have used it before, check the .pdf file that comes with your installation files. There is a long list of codes for the cities, and a link to where you can search a dB for a city's code (it's an xml page). You could maybe have the user put in a city, and then query this xml-interfaced dB, and return the results, inputting into a URL. See what I mean, Vern?

I'm sorry, but what I'm currently using is a copy and paste from a weather info provider. I didn't download or install anything. But if you know of a specific application that will do weather in this "remember my prefs" manner please let me know. Smiling

He has: 1,380 posts

Joined: Feb 2002

OK, sorry, I assumed you were using weather.com

If you mouseover (or click) the link, you see:

www.weatherforyou.com/cgi-bin/hw3/hw3.cgi?forecast=zandh&place=Charlotte&state=nc&zipcode=
'

Just run a php script and have "place" a variable as well as "state". Zipcode is already blank, so leave it so.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.