我想要获取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]);
}];
答案 0 :(得分:0)
在iOS 6中使用facebook SDK:
#import <FacebookSDK/FacebookSDK.h>
并致电:
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
结果应该是您正在寻找的数据。