Retrieve Facebook Account Information in ios 6

倾然丶 夕夏残阳落幕 提交于 2019-12-11 03:12:30

问题


i want retrieve the information of a facebook account on the ios 6 integrated Facebook, now i do it in this way and i can retrieve only the username:

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) {
}
}
}];

i want know how i can retrieve also the Name and Surname of the account and the pic of the user...anyone can help me?


回答1:


Jeffrey is right. Go to this post: Facebook iOS 6 - get user info and implement 2 methods given by Daniel.

After then make sure to make some changes in your application settings on facebook developer account.

  • On main settings page disable sandbox mode
  • Put your applications bundle id
  • Enable facebook login

Then go to Advance settings on the left

  • Select Native/Desktop as App Type
  • make sure App secret in client is NO

Save all settings and it really takes few minutes to populate the changes on server. Finally Must reset you simulator




回答2:


ACAccount is a generic "social" class provided by Apple; it has only limited account information and no knowledge of Facebook data. After obtaining the account, you can instantiate an SLRequest to query the Facebook Graph API, using the account to authenticate it...

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
}];


来源:https://stackoverflow.com/questions/12539549/retrieve-facebook-account-information-in-ios-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!