A very simple means of extracting weather information for inclusion in your website is via a very unknown Google weather API. The API will return weather in a very digestible XML format that you can easily parse for inclusion on any page.
The API requires no key and is seemingly unsupported.
<?php $xml = simplexml_load_file('http://www.google.com/ig/api?weather=ADDRESS'); $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition"); echo $information->attributes(); ?>
A Sample Application for Sydney, Australia
<?php $xml = simplexml_load_file('http://www.google.com/ig/api?weather=Sydney,Australia'); $information = $xml->xpath("/xml_api_reply/weather/current_conditions/condition"); echo $information->attributes(); ?>
Note that I’ve simply replaced ADDRESS with a city and state (although you can use local data as well). You can also replace with a US zip code. The API will return data that looks like this.
Interestingly, the icon data returned points to image files used by the iGoogle front page.
Other Secret API’s
I shouldn’t use the word secret – but they are very much an unknown. Google has a bunch of API’s accessible without a key or any kind of registration; and they return funky data that you can easily incorporate into your website or application.
Given that they’re not widely publicised by Google (and somebody please correct me if I’m wrong), they seemingly come without support, warranty or any kind of guarantee. There’s no mention of them on the Google website.
Google’s Stock API
http://www.google.com/ig/api?stock=VBA will return the latest stock information for Virgin Blue Airlines. http://www.google.com/ig/api?stock=GOOG will return the latest data for Google. Data is returned in an XML format that can be easily fashioned for inclusion on your website.
Other Google API’s
Google already returns its news via a digestible RSS feed, but the News API returns it in a more usable format (http://www.google.com/ig/api?news). There seems to be an API for movies although I haven’t quite figured it out (http://www.google.com/ig/api?movies=90210).
If you liked this article, you may also like:
- Country, State & City from Google’s Geocoding API
- Generate QR Codes on Your Website or WordPress Post with Google Chart Tools
- Google Chart WordPress Shortcode
- Add Your Latest Google Plus Post(s) to Your WordPress Blog (or Generate a Google+ RSS Feed)
- Retrieve Images from the (Depreciated) Google Images API