我試圖將Facebook與我的iOS應用程序集成,但我正在運行到這個障礙。活躍的Facebook訪問令牌iOS錯誤
當我第一次運行該代碼它完美地工作,但它似乎像在Facebook的高速緩存的東西是導致此錯誤:「一個積極的訪問令牌必須用於查詢當前用戶的信息」
我使用這2個功能,試圖上傳照片:
+(BOOL)logInAndPostImage:(UIImage*)image andMessage:(NSString*)message {
NSArray *permissions = [NSArray arrayWithObjects:@"publish_stream", nil];
[FBSession.activeSession closeAndClearTokenInformation];
return [FBSession openActiveSessionWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceOnlyMe
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
if(error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Problem connecting with Facebook" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alert show];
} else {
[self postImage:image andMessage:message];
}
}];
}
+(void)postImage:(UIImage*)image andMessage:(NSString*)message
{
NSLog(@" Access Token Description: %@",[[FBSession activeSession] accessToken].description);
[FBRequestConnection startForUploadPhoto:image completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
[[[UIAlertView alloc] initWithTitle:@"Result"
message:@"Your update has been posted to Facebook!"
delegate:self
cancelButtonTitle:@"Sweet!"
otherButtonTitles:nil] show];
} else {
[[[UIAlertView alloc] initWithTitle:@"Error"
message:@"Yikes! Facebook had an error. Please try again!"
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil] show];
NSLog(@"%@", error);
}
}];
}
當我查詢了激活令牌描述的描述,它實際上是零。所以我想FBSession openActiveSessionWithPublishPermissions:defaultAudience:allowLoginUI:completionHandler:
不會返回一個錯誤,我不生成一個令牌?
任何建議,我如何進一步調試這個錯誤?我已經按照Facebook開發者頁面列出的所有其他設置。