首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Facebook post的权限是使用FBWebDialogs的“唯一的我”

Facebook post的权限是使用FBWebDialogs的“唯一的我”
EN

Stack Overflow用户
提问于 2013-04-30 11:48:45
回答 1查看 2.3K关注 0票数 2

我想张贴文本和链接从iOS应用程序到用户时间线。我复制并粘贴了FBWebDialogs示例。

问题1:帖子出现在我的时间线上,但权限是“只有我一个人”,而不是朋友或公众。

问题2:结果对象(FBWebDialogResult)为空。日志出现在my console.NSLog(@“用户取消故事发布。”);

问题3:预览框的权限是“只有我一个人”,即使我把它设置为public

我的Facebook页面的附加设置:

下面是我的代码:

代码语言:javascript
运行
复制
[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];
             }
         }
     }
 }];

我的app的设置页面默认是“只有我”。我不希望我的所有用户都在这里更改这个设置。

EN

Stack Overflow用户

回答已采纳

发布于 2013-04-30 12:00:24

天哪。我挣扎了一整天,但没有任何进展。我一问问题就找到了答案。

问题是我复制了不恰当的示例代码。我换成了FBSession openActiveSessionWithPublishPermissions,问题解决了。

这是我使用的登录码。我的帖子现在可以公开了。

代码语言:javascript
运行
复制
- (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");                                          }
                                  }];
}
票数 3
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16291837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档