我想获取 Facebook 好友列表并为我的应用发送邀请。
我尝试了以下代码:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *accounts = [accountStore accountsWithAccountType:facebookAccountType];
NSLog(@"%@",accounts); `******//I got the null array ***********`
ACAccount *facebookAccount = [accounts lastObject];
NSString *acessToken = [NSString stringWithFormat:@"%@",facebookAccount.credential.oauthToken];
NSDictionary *parameters = @{@"access_token": acessToken};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/friends"];
SLRequest *feedRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:feedURL
parameters:parameters];
feedRequest.account = facebookAccount;
[feedRequest performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse, NSError *error)
{
NSLog(@"%@",[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
}];