Created
October 7, 2013 11:19
-
-
Save leoru/6866278 to your computer and use it in GitHub Desktop.
Facebook Account type
This file contains 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
// Initialize the account store | |
self.accountStore = [[ACAccountStore alloc] init]; | |
// Get the Facebook account type for the access request | |
ACAccountType *fbAccountType = [self.accountStore | |
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
// Request access to the Facebook account with the access info | |
[self.accountStore requestAccessToAccountsWithType:fbAccountType | |
options:fbInfo | |
completion:^(BOOL granted, NSError *error) { | |
if (granted) { | |
// If access granted, then get the Facebook account info | |
NSArray *accounts = [self.accountStore | |
accountsWithAccountType:fbAccountType]; | |
self.fbAccount = [accounts lastObject]; | |
// Get the access token, could be used in other scenarios | |
ACAccountCredential *fbCredential = [self.fbAccount credential]; | |
NSString *accessToken = [fbCredential oauthToken]; | |
NSLog(@"Facebook Access Token: %@", accessToken); | |
// Add code here to make an API request using the SLRequest class | |
} else { | |
NSLog(@"Access not granted"); | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Здравствуйте, скажите пожалуйста откуда берется fbInfo, делал так;
SLComposeViewController *fb = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSDictionary *fbInfo = [[NSDictionary alloc] init];
[fbInfo allKeysForObject:fb];
Думаю что это не правильно, подскажите как будет правильно, мне нужно вытащить от туда email, да и вообще максимум информации.