我正在按照本教程 在 Facebook SDK 3.1 上实现视图预览帖子,但是当我调用此方法时...
// Ask for publish_actions permissions in context
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
[FBSession.activeSession
reauthorizeWithPublishPermissions:
[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
// If permissions granted, publish the story
[self publishStory];
}
}];
} else {
// If permissions present, publish the story
[self publishStory];
}
...
返回以下错误:
*由于未捕获的异常“com.facebook.sdk:InvalidOperationException”而终止应用程序,原因:“FBSession:尝试重新授权未打开会话的权限”
到底是怎么回事?谢谢!
编辑: 跑我的朋友,非常感谢,但仍然有一个细节......什么时候发布他第一次要求授权应用程序我授权这个秋天
/* * 打开一个具有发布权限的新会话 */
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
defaultAudience:FBSessionDefaultAudienceOnlyMe
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (!error && status == FBSessionStateOpen) {
[self publishStory];
}else{
NSLog(@"error");
//Here I get the error mentioned below
}
}];
}
出现错误:错误:
域 = com.facebook.sdk,代码 = 5