0

我正在尝试使用应用程序中的 flickr.photos.getInfo 方法进行 GET 调用。目标是使用它的 id 获取有关照片的信息。

我的方法:

+(NSDictionary*)photoForId:(NSString *)photoID
{
    NSLog(@"photo id = %@", photoID);
    NSString *request=[NSString stringWithFormat:@"http://api.flickr.com/services/rest/flickr.photos.getInfo&photo_id=%@&format=json&nojsoncallback=1&extras=original_format,tags,description,geo,date_upload,owner_name&page=1&method=flickr.photos.search", photoID];

        NSLog(@"output=%@",[self executeFlickrFetch:request]);
    return [[[self executeFlickrFetch:request]valueForKey:@"photos.photo"]lastObject];

}

执行FlickrFetch 方法:

+ (NSDictionary *)executeFlickrFetch:(NSString *)query
{
    query = [NSString stringWithFormat:@"%@&format=json&nojsoncallback=1&api_key=%@", query, FlickrAPIKey];
    query = [query stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  NSStringFromSelector(_cmd), query);
    NSData *jsonData = [[NSString stringWithContentsOfURL:[NSURL URLWithString:query] encoding:NSUTF8StringEncoding error:nil] dataUsingEncoding:NSUTF8StringEncoding];
    NSError *error = nil;
    NSDictionary *results = jsonData ? [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves error:&error] : nil;
    return results;
}

现在这个调用返回 null。我知道执行 fetch 工作,因为它是由摄影师或地点获取照片。只需要弄清楚照片ID。

4

1 回答 1

0

这是正确的要求:

NSString *request=[NSString stringWithFormat:@"http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&photo_id=%@&format=json&nojsoncallback=1&extras=original_format,tags,description,geo,date_upload,owner_name&page=1", photoID];
于 2012-12-06T02:27:30.550 回答