Skip to content

Instantly share code, notes, and snippets.

@cyhsutw
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save cyhsutw/b016082ff8a302f30245 to your computer and use it in GitHub Desktop.

Select an option

Save cyhsutw/b016082ff8a302f30245 to your computer and use it in GitHub Desktop.
FBAPICall.m
void(^requestCompletionHandler)(FBRequestConnection *, NSDictionary<FBGraphUser> *, NSError *);
requestCompletionHandler = ^(FBRequestConnection *conn,
NSDictionary<FBGraphUser> *user,
NSError *err){
if(!err){
NSLog(@"Successfully fetched user info!");
NSLog(@"userInfo = %@", user);
NSLog(@"These will work:");
NSLog(@"email:\t%@", [user objectForKey:@"email"]);
NSLog(@"gender:\t%@", [user objectForKey:@"gender"]);
}else{
NSLog(@"Fail to fetch user data!");
}
};
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile", @"email"]
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if(!error){
NSLog(@"Successfully logged in!");
[[FBRequest requestForMe] startWithCompletionHandler:requestCompletionHandler];
}else{
NSLog(@"Fail to log in!");
}
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment