【问题标题】:Facebook iOS SDK Dialog parametersFacebook iOS SDK 对话框参数
【发布时间】:2011-01-05 23:10:27
【问题描述】:

这可能是一个 n00b 问题,但尽管如此...我在 iPad 应用程序中使用 Facebook SDK 时遇到了一点问题:当我使用 [facebook dialog:@"feed" andDelegate:self]; 显示对话框时,我看不到任何可以更改的方法我要分享的内容的标题、内容或 URL。

在他们的 Demo App 中,Facebook 有以下代码:

- (IBAction)publishStream:(id)sender {

  SBJSON *jsonWriter = [[SBJSON new] autorelease];

  NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary 
  dictionaryWithObjectsAndKeys: @"Always Running",@"text",@"http://itsti.me/",
                                @"href", nil], nil];

  NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];
  NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                               @"a long run", @"name",
                               @"The Facebook Running app", @"caption",
                               @"it is fun", @"description",
                               @"http://itsti.me/", @"href", nil];
  NSString *attachmentStr = [jsonWriter stringWithObject:attachment];
  NSMutableDictionary* params = [NSMutableDictionary
                                 dictionaryWithObjectsAndKeys:
                                 @"Share on Facebook",  @"user_message_prompt",
                                 actionLinksStr, @"action_links",
                                 attachmentStr, @"attachment",
                                 nil];


  [_facebook dialog:@"feed"
          andParams:params
        andDelegate:self];

}

但是,当我按下 publishStream 按钮时,对话框中没有显示这些字符串! :S

是不是我做的不对?我在那个 Demo App 中改变的只是 Facebook kAppId 和 URL Scheme。

【问题讨论】:

    标签: facebook ipad ios


    【解决方案1】:

    我意识到这已经被回答了,但我发现这是正确的答案。它遵循FB拥有的here。图像和/或链接实际上显示在对话框中。 stream.publish 并没有为我做出改变。此外,dialog 页面显示 stream.publish 已旧。

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
                                   @"http://fbrell.com/f8.jpg", @"picture",
                                   @"Facebook Dialogs", @"name",
                                   @"Reference Documentation", @"caption",
                                   @"Dialogs provide a simple, consistent interface for apps to interact with users.", @"description",
                                   @"Facebook Dialogs are so easy!",  @"message",
                                   nil];
    
    
    [_facebook dialog:@"feed"
            andParams:params
          andDelegate:self];
    

    【讨论】:

    • 这是正确答案。 Stream.publish 已过时。提要是正确的,但示例是错误的。
    • 显示对话框,但消息为空。文档说“消息”字段现在被忽略:developers.facebook.com/docs/reference/dialogs/feed
    • 愚蠢的是,他们没有为此更新示例。感谢您的提醒。
    • @MrRogers,我有一个相关(但不相同)的问题,我认为您可能知道答案。你介意看看stackoverflow.com/questions/11993457/… 吗?
    • 我可以使用 UIImage 代替图片的 HTTP url 吗?
    【解决方案2】:

    我遇到了同样的问题。 这是我找到的解决方案:以这种方式更改您的代码:

    [_facebook dialog:@"stream.publish"
             andParams:params
             andDelegate:self];
    

    使用 stream.publish 而不是 feed。

    【讨论】:

    • 太棒了,谢谢!您是如何发现需要 stream.publish 而不是 feed 的?
    • 嗯。当我尝试此操作时,Facebook 对话框返回并声明不允许使用“h”......无论 h 是什么。 :(
    • 正如@MrRogers 所指出的,stream.publish API 已被弃用。你应该关注他的correct answer
    • @dbfranz:这已经过时了。不再工作。请改用罗杰斯先生的回答。
    【解决方案3】:

    嗯.. 我没有使用示例应用程序,但我认为如果你想在墙上发布一些东西,你需要做一个 POST。在这里查看这个问题和我的答案:Post to user's Facebook wall with iPhone using latest FBConnect SDK

    总结一下,这里是我使用的方法:

    - (void)requestWithGraphPath:(NSString *)graphPath
                       andParams:(NSMutableDictionary *)params
                   andHttpMethod:(NSString *)httpMethod
                     andDelegate:(id <FBRequestDelegate>)delegate;
    

    像这样:

    [_facebook requestWithGraphPath:@"[user_id]/feed" 
                              andParams:[NSMutableDictionary dictionaryWithObject:@"test wall post" forKey:@"message"]
                          andHttpMethod:@"POST"
                            andDelegate:self];
    

    [user_id]的墙上发表评论。

    【讨论】:

    • 问题是使用dialog:而不是背景requestWithGraphPath:方法。
    猜你喜欢
    • 2011-09-28
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 2011-05-11
    • 2012-12-03
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    相关资源
    最近更新 更多