Created
September 18, 2012 18:19
-
-
Save wbroek/3744808 to your computer and use it in GitHub Desktop.
iOS 6 Facebook Open Graph call
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
ACAccountStore *store = [[ACAccountStore alloc] init]; | |
ACAccountType *facebookAccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
NSDictionary *FacebookOptions = @{ACFacebookAppIdKey: @"XXXXXXXXXX",ACFacebookPermissionsKey: @[@"email"],ACFacebookAudienceKey:ACFacebookAudienceEveryone}; | |
[store requestAccessToAccountsWithType:facebookAccountType options:FacebookOptions completion:^(BOOL granted, NSError *error) { | |
if (granted) | |
{ | |
NSArray *accounts = [store accountsWithAccountType:facebookAccountType]; | |
if ([accounts count]>0) { | |
ACAccount *facebookAccount = [accounts lastObject]; | |
SLRequest *facebookRequest = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://graph.facebook.com/me"] parameters:@{@"":@""}]; | |
[facebookRequest setAccount:facebookAccount]; | |
[facebookRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { | |
// Read the returned response | |
}]; | |
} | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment