2013-12-08 42 views
0

我试着调用FBRequest:requestForMe:startWithCompletionHandler,无法让它在我自己的代码中工作,所以试图将它添加到示例项目SessionLoginSample中,但仍然得到结果相同的结果是零。调用FBRequest:requestForMe:返回零结果

我已经添加到示例项目内的UpdateView方法,但它并没有区别的地方放置,ID始终为零:

- (void)updateView { 
    // get the app delegate, so that we can reference the session property 
    SLAppDelegate *appDelegate = [[UIApplication sharedApplication]delegate]; 
    if (appDelegate.session.isOpen) { 
     // valid account UI is shown whenever the session is open 
     [self.buttonLoginLogout setTitle:@"Log out" forState:UIControlStateNormal]; 
     [self.textNoteOrLink setText:[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@", 
           appDelegate.session.accessTokenData.accessToken]]; 

     FBRequest *me = [FBRequest requestForMe]; 
     [me startWithCompletionHandler:^(FBRequestConnection *connection, 
             id result, 
             NSError *error) { 
      NSDictionary<FBGraphUser> *my = (NSDictionary<FBGraphUser> *) result; 
      NSLog(@"My dictionary: %@", my.first_name); 
     }]; 


    } else { 
     // login-needed account UI is shown whenever the session is closed 
     [self.buttonLoginLogout setTitle:@"Log in" forState:UIControlStateNormal]; 
     [self.textNoteOrLink setText:@"Login to create a link to fetch account data"]; 
    } 
} 

的NSError包含域:com.facebook.sdk代码: 5.

经过一些谷歌搜索和实验后,我通过在它之前添加一个对[FBSession setActiveSession:appDelegate.session]的调用来运行requestForMe,但是我无法将这个工作代码转移到我自己的项目中,相同的错误代码为5,但是我看不出我的项目代码与示例项目的区别。

回答

0

经过大量谷歌搜索我设法通过添加以下行调用之前requestForMe解决这个

[FBSession setActiveSession:appDelegate.session]。