小编Sar*_*jay的帖子

从iOS的ACAccountStore获取Facebook uid?

嗨,我想从iOS 6中的ACAccountStore获取Facebook用户的UID

    self.accountStore = [[ACAccountStore alloc]init];

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

    NSString *key = @"01234567890123";
    NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:key,ACFacebookAppIdKey,@[@"email"],ACFacebookPermissionsKey, nil];


        [self.accountStore requestAccessToAccountsWithType:FBaccountType options:dictFB completion:
         ^(BOOL granted, NSError *e) {
             if (granted) {
                 NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType];

                 //it will always be the last object with single sign on
                 self.facebookAccount = [accounts lastObject];

                 //i Want to get the Facebook UID and log it here

                 NSLog(@"facebook account =%@",self.facebookAccount);

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

             }
         }];
Run Code Online (Sandbox Code Playgroud)

self.facebookAccount …

iphone xcode facebook ios6 social-framework

9
推荐指数
2
解决办法
5783
查看次数

标签 统计

facebook ×1

ios6 ×1

iphone ×1

social-framework ×1

xcode ×1