我已经更新了新的 FaceBook SDK (3.1) 并尝试集成到我以前使用旧的单例类中。我的代码:
-(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];
}
现在,如果我第二次尝试分享,我会收到以下错误:
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;
};
}
知道如何处理访问令牌吗?