如何从Facebookgraphicsapi iOS获得具有特定ID的图像?

在我的应用程序中,我试图从Facebook页面照​​片/相册中获取特定图像。 我可以在NSArray中得到所有的图像,但我应该如何查询我想要的特定图像。

这是我的url:@“ https://graph.facebook.com/v2.0/albumid/photos ”,这给了我一个图像数组与他们的源url,但他们是没有图像ID,我可以用来获得我想要的图像。

任何帮助,将不胜感激。

谢谢,

我想你需要这个, http://graph.facebook.com/v2.0/me?fields=albums.fields(photos.fields(id , source , name , picture))

从这个链接你可以得到个人照片的id ,来源和图片。

你首先从它获得url,然后加载到UIImageViewurl。

  AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager GET:[NSString stringWithFormat:@"http://graph.facebook.com/%@/?fields=picture",fbId] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NLog(@"JSON %@",responseObject); NSDictionary *pic = [responseObject objectForKey:@"picture"]; NSDictionary *data = [pic objectForKey:@"data"]; NSString *url = [data objectForKey:@"url"]; [imageView setImageWithURL:[NSURL URLWithString:url]]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NLog(@"Error: %@", error); }]; 

对于那些正在使用最新的SDK

self.arrayMedia = [[NSMutableArray alloc] init];

 [[[FBSDKGraphRequest alloc] initWithGraphPath:@"/me/albums" parameters:@{@"fields": @"id"} tokenString:[[NSUserDefaults standardUserDefaults] objectForKey:@"FACEBOOK_ACCESSTOKEN"] version:nil HTTPMethod:@"GET"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { NSLog(@"result albums:%@",result); NSLog(@"Error %@",error.description); for (NSDictionary *dict in result[@"data"]) { [[[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"/%@/photos", dict[@"id"]] parameters:@{@"fields": @"id,url,picture"} tokenString:[[NSUserDefaults standardUserDefaults] objectForKey:@"FACEBOOK_ACCESSTOKEN"] version:nil HTTPMethod:@"GET"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { for (NSDictionary *dict in result[@"data"]) { [self.aryMedia addObject:dict]; } }]; } }];