I need to get profile picture from profile album only .
I know how to get profile picture directly from userId and i know how to get the photos of album.
the problem is -
I need to get all the photos from profile album and need to set the profile picture on first position .
If i get the profile picture directly from userId and after that i place the profile album photos then the profile picture will repeat twice because it's in album too.
So, i need some solution like i'll identify the profile picture from profile album .
any link,tutorial,suggestion,idea will be great help.
Update This will definitely help you.
[FBRequestConnection startWithGraphPath:@"me?fields=albums.fields(name,photos.fields(name,picture,source))"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
//NSLog(@"result %@",result);
NSString * anImage;
NSArray* albums = result[@"albums"][@"data"];
NSUInteger index = [albums indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [obj[@"name"] isEqualToString: @"Profile Pictures"];
}];
if (index != NSNotFound) {
NSDictionary *profileImages = albums[index];
NSDictionary *photos = profileImages[@"photos"];
NSArray *data = photos[@"data"];
for (NSDictionary *picture in data) {
NSString *date = picture[@"created_time"];
NSString *id = picture[@"id"];
NSString *pictureUrl = picture[@"picture"];
NSString *sourceUrl = picture[@"source"];
}
}
}];
The reply above (below once I added my reply) helps me. I upvote, the updated solution for SDK V4:
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"albums.fields(name,photos.fields(name,picture,source,created_time))"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
//NSLog(@"result %@",result);
NSString * anImage;
NSArray* albums = result[@"albums"][@"data"];
NSUInteger index = [albums indexOfObjectPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [obj[@"name"] isEqualToString: @"Profile Pictures"];
}];
if (index != NSNotFound) {
NSDictionary *profileImages = albums[index];
NSDictionary *photos = profileImages[@"photos"];
NSArray *data = photos[@"data"];
for (NSDictionary *picture in data) {
NSString *date = picture[@"created_time"];
NSString *id = picture[@"id"];
NSString *pictureUrl = picture[@"picture"];
NSString *sourceUrl = picture[@"source"];
}
}
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.