Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Just a small piece of code to get the basic info + profile picture
+ (void(^)())facebookImageBlockWithCompletionHandler:(void(^)(id profilePicture, id userInformation, NSError *error))completionHandler
{
void(^facebookBlock)()= ^{[FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"email"]
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
{
if (!error)
{
if (status != FBSessionStateOpen)
{
// Don't do anything, just return it
return;
}
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *userInfoConnection, id userInfo, NSError *error1)
{
[FBRequestConnection startWithGraphPath:@"me?fields=picture.type(large)" completionHandler:^(FBRequestConnection *userPictureConnection, id profilePicture, NSError *errorr2)
{
if(errorr2)
{
completionHandler(nil,nil,error);
}
else
{
completionHandler(profilePicture,userInfo,nil);
}
}];
}];
}
else
{
completionHandler(nil,nil,error);
}
}];};
return facebookBlock;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment