我想发布文字并从iOS应用链接到用户时间线。我复制并粘贴FBWebDialogs示例。
问题1: 该帖子出现在我的时间表中,但是权限是“只有我”,而不是朋友或公共。
问题2: 结果对象(FBWebDialogResult)为零。日志显示在我的控制台中.NSLog(@“用户取消的故事发布。”);
问题3: 即使我将其设置为公开,预览框的权限也是“只有我”
我的Facebook页面的附加设置:
这是我的代码:
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or publishing a story.
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(@"User canceled story publishing.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
NSLog(@"User canceled story publishing.");
} else {
NSString *msg = [NSString stringWithFormat:
@"Posted story, id: %@",
[urlParams valueForKey:@"post_id"]];
[[[UIAlertView alloc] initWithTitle:@"Result"
message:msg
delegate:nil
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}
}
}
}];
我的应用程序的设置页面默认为“仅限我”。我不希望我的所有用户都在这里更改此设置。
答案 0 :(得分:3)
OMG。我整天都挣扎但没有进步。我一提问就找到了解决方案。
问题是我复制了不合适的示例代码。改为[FBSession openActiveSessionWithPublishPermissions],问题解决了。
这是我使用的登录代码。我的帖子现在可以公开了。
- (void)buttonRequestClickHandler:(id)sender {
// FBSample logic
// Check to see whether we have already opened a session.
if (FBSession.activeSession.isOpen) {
// login is integrated with the send button -- so if open, we send
// [self sendRequests];
NSLog(@"Login in facebook");
} else {
NSArray *permission = [NSArray arrayWithObjects:@"publish_actions", nil];
[FBSession openActiveSessionWithPublishPermissions:permission defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
// if login fails for any reason, we alert
if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
// if otherwise we check to see if the session is open, an alternative to
// to the FB_ISSESSIONOPENWITHSTATE helper-macro would be to check the isOpen
// property of the session object; the macros are useful, however, for more
// detailed state checking for FBSession objects
} else if (FB_ISSESSIONOPENWITHSTATE(status)) {
// send our requests if we successfully logged in
NSLog(@"Login in facebook"); }
}];
}