Created
April 1, 2014 15:13
-
-
Save altyus/9916207 to your computer and use it in GitHub Desktop.
Facebook Get Friends List Social Framework
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)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