2013-12-08 70 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]。