Search code examples
iosiphoneyahoo-apiyahoo-weather-api

How to get WOEID without using yahoo services?


Is there any other alternative to get WOEID of a place, other than yahoo services? Is there any third party library which is free?


Solution

  • You can get it by making a query request using the city name you want and hitting yahoo service with code like this:

    NSString *request = [NSString stringWithFormat:@"http://query.yahooapis.com/v1/public/yql?q=select * from geo.places where text=\"%@\"&format=xml", cityName];
    NSString *encRequest = [request stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *URL = [NSURL URLWithString:encRequest];
    

    I've put the complete example for this in github, but this is a solution just for testing purposes. You should use the official way (and pay if needed) for a commercial app.