2

我试图在我的应用程序中从 facebook 获取一些基本信息。我运行这段代码:

FBSession *session = [[FBSession alloc] initWithAppID:APP_ID permissions:nil defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:nil];
NSLog(@"I get this message");

[session openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    NSLog(@"It never calls this");
}];

似乎从未调用过处理程序。我被带到 facebook 并带回来,但没有任何反应。有人有想法么?

4

1 回答 1

2

我仍然不知道为什么它不起作用,但这就是起作用的。

FBSession *session = [[FBSession alloc] initWithAppID:APP_ID permissions:nil defaultAudience:FBSessionDefaultAudienceEveryone urlSchemeSuffix:nil tokenCacheStrategy:nil];
[FBSettings setDefaultAppID: APP_ID];
[FBSession setActiveSession:session];
[FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"email"] allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
    if ([session isOpen]) {
        [FBRequestConnection 
          startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                               id<FBGraphUser> FBUser,
                                               NSError *error) {
              if (!error){
                //do whatever you need to.
              }
         }];
     }
}];
于 2013-07-15T21:46:31.967 回答