2013-01-07 49 views
0

我已經更新了新的FaceBook SDK(3.1),並嘗試將之前與舊的一起工作的單例類集成到一起。我的代碼:新的facebook sdk for ios單例實現

-(void)postFacebook { 
    if ([FBSession.activeSession isOpen]) { 
     [[AAFacebook sharedInstance] postToWallWithScreenshot]; 
    } else { 
     [[AAFacebook sharedInstance] openSessionWithAllowLoginUI:YES]; 
    } 
} 

和公開會議法:

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI { 

    return [FBSession openActiveSessionWithReadPermissions:nil 
               allowLoginUI:allowLoginUI 
             completionHandler:^(FBSession *session, FBSessionState state, NSError *error) { 
              [self sessionStateChanged:session state:state error:error]; 
             }]; 
} 



- (void)sessionStateChanged:(FBSession *)session 
         state:(FBSessionState)state 
         error:(NSError *)error 
{ 
    NSLog(@"Is FBSession opened? A: %i", FBSession.activeSession.isOpen); 

    switch (state) { 

     case FBSessionStateOpen: { 

      NSLog(@"Login succesfully & post to FaceBook!"); 

     } 
      break; 
     case FBSessionStateClosed: { 
      [FBSession.activeSession closeAndClearTokenInformation]; 
     } 
      break; 
     case FBSessionStateClosedLoginFailed: { 
      NSLog(@"FaceBook login failed."); 
     } 
      break; 

     default: 
      break; 
    } 

    [[NSNotificationCenter defaultCenter] postNotificationName:kAAFacebookNoficationChanged 
                 object:session]; 

} 

現在我碰到下面的錯誤,如果我想分享的第2次:

2013-01-07 10:28:26.894[2098:907] Error: HTTP status code: 400 
2013-01-07 10:28:26.904[2098:907] Photo uploaded failed :({ 
    "com.facebook.sdk:HTTPStatusCode" = 400; 
    "com.facebook.sdk:ParsedJSONResponseKey" =  { 
     body =   { 
      error =    { 
       code = 2500; 
       message = "An active access token must be used to query information about the current user."; 
       type = OAuthException; 
      }; 
     }; 
     code = 400; 
    }; 
} 

任何想法如何處理訪問令牌?

回答

0

我明白了。似乎FB SDK爲我處理會話令牌。