0

我想获取 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]);
     }];
4

1 回答 1

0

在 iOS 6 中使用 facebook SDK:

#import <FacebookSDK/FacebookSDK.h>

并致电:

[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];

结果应该是您要查找的数据。

于 2013-05-07T13:14:20.670 回答