如何使用Facebook oauth令牌制作FBSession?

时间:2014-06-23 10:28:43

标签: ios facebook social-framework

我使用社交框架登录Facebook并成功获得了令牌。您知道如何将其设置为Facebook FBsession中的SDK吗?我想用这个令牌进行会话,然后将其设置为FBSession.activeSession,所以一切都是同步的:)。 谢谢你们。

ACAccountType *facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

NSDictionary *options = @{
@"ACFacebookAppIdKey" : @"123456789",
@"ACFacebookPermissionsKey" : @[@"publish_stream"],
@"ACFacebookAudienceKey" : ACFacebookAudienceEveryone}; // Needed only when write permissions are requested

[self.accountStore requestAccessToAccountsWithType:facebookAccountType options:options 
                             completion:^(BOOL granted, NSError *error) {
                                 if (granted)
                                 {
                                     NSArray *accounts = [self.accountStore
                                                          accountsWithAccountType:facebookAccountType];
                                     self.facebookAccount = [accounts lastObject];
                                     ACAccountCredential *facebookCredential = [facebookAccount credential];
                                    NSString *accessToken = [facebookCredential oauthToken];

                                 } else {
                                     NSLog(@"%@",error);
                                     // Fail gracefully...
                                 }
                             }];

0 个答案:

没有答案