2

我想在 ios 6 集成的 Facebook 上检索 facebook 帐户的信息,现在我这样做了,我只能检索用户名:

ACAccountType *accountTypeF = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
        if(granted) {
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountTypeF];

            ACAccount *facebookAccount = [accountsArray objectAtIndex:0];
            if (facebookAccount.username) {
}
}
}];

我想知道如何检索帐户的姓名和姓氏以及用户的图片...有人可以帮助我吗?

4

2 回答 2

8

杰弗里是对的。转到这篇文章:Facebook iOS 6 - 获取用户信息并实现 Daniel 给出的 2 个方法。

然后确保在您的应用程序设置上进行一些更改facebook developer account

  • 在主设置页面禁用sandbox mode
  • 把你的应用程序bundle id
  • EnableFacebook登入

然后进入Advance左边的设置

  • 选择Native/DesktopApp Type
  • 确保App secret in clientNO

保存所有设置,在服务器上填充更改确实需要几分钟。最后Must reset you simulator

于 2013-04-11T10:08:43.963 回答
1

ACAccount是 Apple 提供的通用“社交”类;它只有有限的账户信息,对 Facebook 数据一无所知。获取账号后,可以实例化一个SLRequest查询Facebook Graph API,使用账号进行身份验证...

NSURL* URL = [NSURL URLWithString:@"https://graph.facebook.com/me"];

SLRequest* request = [SLRequest requestForServiceType:SLServiceTypeFacebook
                                    requestMethod:SLRequestMethodGET
                                              URL:URL
                                       parameters:nil];

[request setAccount:account]; // Authentication - Requires user context

[request performRequestWithHandler:^(NSData* responseData, NSHTTPURLResponse* urlResponse, NSError* error) {
  // parse the response or handle the error
}];
于 2012-09-24T23:25:22.637 回答