Skip to content

Instantly share code, notes, and snippets.

@leoru
Created October 7, 2013 11:19
Show Gist options
  • Save leoru/6866278 to your computer and use it in GitHub Desktop.
Save leoru/6866278 to your computer and use it in GitHub Desktop.
Facebook Account type
// 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");
}
}];
@sadisasha
Copy link

Здравствуйте, скажите пожалуйста откуда берется fbInfo, делал так;

SLComposeViewController *fb = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSDictionary *fbInfo = [[NSDictionary alloc] init];
[fbInfo allKeysForObject:fb];

Думаю что это не правильно, подскажите как будет правильно, мне нужно вытащить от туда email, да и вообще максимум информации.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment