Last active
August 29, 2015 14:05
-
-
Save cyhsutw/b016082ff8a302f30245 to your computer and use it in GitHub Desktop.
FBAPICall.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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