Search code examples
iosjsonflickrcs193pitunesu

Flickr getTopPlacesList returning 0


I found some posts complaining about the fact that the method in the title for Flickr API didn't work. All post I've found are old and most of them tell that later the issue has been resolved. Now I'm trying to use this method again(for iTunesU Stanford course) but again it's returning 0 since yesterday evening. Anyone other is meeting this problem or could try to call the method to see if I'm the only one or not? A lot of thanks for the answers..


Solution

  • After next two weeks flickr.places.getTopPlacesList still doesn't work.

    But if you need it just for the purpose of the Stanford Course (CS193P), you can use other method to get a places list.

    Below a simple example of some:

    /* Returns an alternate (statically defined) places list. 
       To be used when Flickr flickr.places.getTopPlacesList returns an empty set.
    */
    + (NSArray*) alternatePlaces
        {
            NSMutableArray* places = [NSMutableArray new];
            NSArray* placesNames = [[NSArray alloc] initWithObjects:@"New York", 
              @"Los Angeles", @"Tokyo", @"Moscow", @"Brasília", @"Beijing", 
              @"Shanghai", @"Hong Kong", @"Phnom Penh", @"Siem Reap", @"Sydney", 
              @"Liverpool", @"Brisbane", nil];
            NSString* requestTemplate = @"https://api.flickr.com/services/rest/?method=flickr.places.find&query=%@";
    
            for (NSString* placeName in placesNames) {
                NSString* request = [NSString stringWithFormat:requestTemplate, 
                  placeName];
                [places addObjectsFromArray:
                  [[self executeFlickrFetch:request] valueForKeyPath:@"places.place"]];
            }
    
            return places;
        }
    

    You can limit it further to use only places with place_type_id=7 as originally in topPlaces method. Also using this alternate method, some places could have no pictures. But besides those limitations for the purpose of this course it could substitute for topPlaces method.