
Please go to http://www.codeplex.com/awAPI the project and documentation is there.
/Roman
This is a little guide on how to use the Google Weather API
Use this XML file for output in Fahrenheit:
http://www.google.com/ig/api?weather=Drammen
And this one for Celsius:
http://www.google.co.uk/ig/api?weather=Drammen
And here is the sample C# parser (Celsius Version):
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Net;
///Code by Roman Alifanov - API by Google
///Posted on http://animaonline.blogspot.com
namespace GoogleWeatherAPI_Parser
{
class Program
{
static void Main(string[] args)
{
int i = 0;
XmlNodeList GWP_NodeList = GoogleWeatherAPI_Parser(@"http://www.google.co.uk/ig/api?weather=Drammen").SelectNodes("xml_api_reply/weather/current_conditions");
Console.WriteLine("Current weather in Drammen: " + GWP_NodeList.Item(i).SelectSingleNode("temp_c").Attributes["data"].InnerText);
Console.ReadLine();
}
private static XmlDocument GoogleWeatherAPI_Parser(string baseUrl)
{
HttpWebRequest GWP_Request;
HttpWebResponse GWP_Response = null;
XmlDocument GWP_XMLdoc = null;
try
{
GWP_Request = (HttpWebRequest)WebRequest.Create(string.Format(baseUrl));
GWP_Request.UserAgent = @"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4";
GWP_Response = (HttpWebResponse)GWP_Request.GetResponse();
GWP_XMLdoc = new XmlDocument();
GWP_XMLdoc.Load(GWP_Response.GetResponseStream());
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
GWP_Response.Close();
return GWP_XMLdoc;
}
}
}
Enjoy :P
Back to Home


22 comments:
Респект за пост и привет от мурманска
Thank you for valuable information.
by,
http://www.a2zinterviewquestions.com
http://mygadgetguru.blogspot.com
Is it possible for between dates and enter city name or zip code.
by,
http://www.a2zinterviewquestions.com
http://mygadgetguru.blogspot.com
Yes, it is
Hello,
why
latitude_e6
longitude_e6
are empty?
Thanks
Andrea
I'm afraid this function is not fully implemented by Google, however you can use this GeoCoder (http://blog.donnfelker.com/2007/03/13/CGoogleGeocodeLatitudeAndLongitudeClass.aspx)
to get the coordinates of a city
Sample Source:
cord = GoogleGeocoder.Geocode.GetCoordinates("Drammen");
string MapUrl = @"http://maps.google.com/maps?ie=UTF8&ll=" + cord.Latitude +"," + cord.Longitude +"&spn=2.589805,5.141602&z=12";
Please, feel free to contact me if you encounter any problems :)
- Roman
you can using yahoo weather also
api etc!
Very good tip.
Congratulation.
I think i will'use it on this Travel in Tuscany Website
Does anyone know where the offical google doc is on this?
I don't think that there are any official google docs on that
can anyone send me a sample files which can access google infomation?
I really appreciate your help. I need it urgently.
Thank you again.
my email is:
itbird@gmail.com
Have you tried reading through the post? The code is there. :)
You may find this interesting too
http://codeplex.com/awapi
/Roman
Please contact me directly if you need any help.
Hi.
Just wondering if the code needs the line with GWP_Request.UserAgent...
Nope, It now doesn't
Please go to
http://codeplex.com/aWAPI
I will be releasing version 2.1 soon :)
Hi.
I wanted to ask, the frequency the measurements are taken. I ve checked the measurements against those from freemeteo.com and they are slightly different. The time that the XML shows is Greenwich time ?
Hello! Well it seems like the "current_date_time" is in GMT, I'm not sure however, but I'll see what I can find out about it :)
"Please go to
http://codeplex.com/aWAPI
I will be releasing version 2.1 soon :)"
I am mostly interest about the frequency of the measurements. I mean, I will probably want to find the weather conditions in an interval of +/- 30 min. So, if measurements have been taken like 2 hours before, that won't be quite good, at least for me :) .
It's Reallly good, i got what i want to find that how can include google weather in our page. Great dude....
I gathered more info as well regarding the google weather API and posted it on my site.
Google weather api in flash and PHP
It's basically a PHP back end proxy that feeds a flash client app. Now that the back stuff works I will now be working on cleaning up the client interface :)
A real time saver!!!
The smack down on simple weather.
Thanks again dude.
Post a Comment