Skip to content

Instantly share code, notes, and snippets.

@altyus
Created April 1, 2014 15:13
Show Gist options
  • Save altyus/9916207 to your computer and use it in GitHub Desktop.
Save altyus/9916207 to your computer and use it in GitHub Desktop.
Facebook Get Friends List Social Framework
- (void)getFacebookFriendsListWithCompletion:(void(^)(NSArray *friendsDictionaries))completion
{
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/friends"];
ACAccountType *accountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *accounts = [self.accountStore accountsWithAccountType:accountType];
NSDictionary *params = @{@"limit": @5000,
@"offset": @0};
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:feedURL parameters:params];
[request setAccount:[accounts lastObject]];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
id responseObject = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingAllowFragments error:nil];
NSArray *friendDictionaries = ((NSDictionary *)responseObject)[@"data"];
completion(friendDictionaries);
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment