I need to fetch the weather information based on the user\'s current location. Please provide me the Google API to get the weather info.
I am using http://www.google.com/
Google Weather API is down. Check out the following alternatives:
Open Weather Map
National Digital Forecast
Weather.com
I've been using the first link. Its free like Open Street Maps.
EDIT:
Here's the basic code to get the JSON:
NSError *error = nil;
NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://openweathermap.org/data/2.1/find/city?lat=32.85190&lon=57.65878&cnt=1&type=JSON"]];
if (jsonData) {
id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
if (error) {
NSLog(@"error is %@", [error localizedDescription]);
// Handle Error and return
return;
}
NSArray *keys = [jsonObjects allKeys];
// values in foreach loopDic]
for (NSString *key in keys) {
NSLog(@"%@ is %@",key, [jsonObjects objectForKey:key]);
}
} else {
// Handle Error
}
Add that to the viewDidLoad