Facebook iOS SDK对话框参数

The*_*ter 20 facebook ipad ios

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

在他们的演示应用程序中,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];

}
Run Code Online (Sandbox Code Playgroud)

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

有什么我不对的吗?我在演示应用程序中改变的是Facebook kAppId和URL Scheme.

Mr *_*ers 30

我意识到这已经回答了,但我发现这是正确的答案.它遵循FB在这里所拥有的.图像和/或链接实际显示在对话框中. stream.publish没有为我做出改变.此外,对话框页面显示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];
Run Code Online (Sandbox Code Playgroud)

  • 这是正确的答案.Stream.publish已过时.Feed是正确的,但示例是错误的. (2认同)
  • 对话框显示,但消息为空.Docs说现在忽略了'message'字段:http://developers.facebook.com/docs/reference/dialogs/feed/ (2认同)

小智 19

我有同样的问题.这是我找到的解决方案:以这种方式更改代码:

[_facebook dialog:@"stream.publish"
         andParams:params
         andDelegate:self];
Run Code Online (Sandbox Code Playgroud)

使用stream.publish而不是feed.

  • 正如@MrRogers所指出的那样,不推荐使用stream.publish API.你应该按照他的[正确答案](http://stackoverflow.com/questions/4610153/facebook-ios-sdk-dialog-parameters/6739887#6739887)来代替. (2认同)