在iphone上使用facebook sdk发布链接

Jon*_*an. 2 iphone facebook objective-c

我有演示版Facebook应用程序,没有任何修改,这是代码:

  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)

然而,这不会发布链接,事实上它只发布用户输入的正常状态.

如何使用最新版本的facebook(图表api?)在iPhone上使用Facebook SDK发布链接

我找不到任何关于如何使用facebook sdk从iphone应用发布链接的地方.

Jon*_*an. 7

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

问题是facebook更新了Web上的API,但没有更新SDK,因此虽然@"feed"API更新后对话框的名称正确,但旧stream.publish代码仍在代码中使用.因此,要使params工作并实际上成为您必须使用的消息的一部分:

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

来源于此

另请参阅iPortable对facebook的另一个错误的回答.