如何使用 iOS 应用程序将内容分享到 Facebook 上特定朋友的墙

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6949572/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:58:05  来源:igfitidea点击:

How to use share content to specific friend's wall on Facebook from an iOS app

iosfacebook

提问by TMC

It's straightforward to use Facebook the Javascript SDK and FB.ui to trigger the "feed" dialog to share on your wall.

使用 Facebook Javascript SDK 和 FB.ui 触发“提要”对话框以在您的墙上分享非常简单。

However, this shares on your wall with everyone. I'm looking for a way to share on a specific friend's wall and not finding any answers in the Facebook dev documentation.

但是,这与大家共享在您的墙上。我正在寻找一种在特定朋友的墙上分享的方法,但在 Facebook 开发文档中找不到任何答案。

I was about to give up but them saw this articlewritten June 2011 which shows FB sharing UI that shows that you can change the scope of your sharing:

我正要放弃,但他们看到了这篇写于 2011 年 6 月的文章,其中显示了 FB 共享 UI,表明您可以更改共享范围:

Screenshot of FB sharing dialog with scoping

带有范围的 FB 共享对话框的屏幕截图

I can't find any information that shows how to trigger this dialog that exposes those options. I've used this sample code from FB dev docs:

我找不到任何显示如何触发此公开这些选项的对话框的信息。我使用了来自FB dev docs 的示例代码:

<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <body>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <div id="fb-root"></div>
    <script>
      // assume we are already logged in
      FB.init({appId: '1234567890', xfbml: true, cookie: true});

      FB.ui({
          method: 'feed',
           link: 'https://developers.facebook.com/docs/reference/dialogs/'
          });
     </script>
  </body>
</html>

However, this bring up a dialog that is essentially like the following. Notice no scoping options like the earlier screenshot:

但是,这会弹出一个本质上如下所示的对话框。请注意,没有像前面的屏幕截图那样的范围选项:

enter image description here

在此处输入图片说明

Note: Even though I'm asking about the Javascript SDK and showing HTML, I ultimately I want to use the Facebook iOS SDK to share a link from my iOS app to an individual friend of the user that's logged into my app (while letting that user select which friend to share to).

注意:尽管我在询问 Javascript SDK 并显示 HTML,但我最终还是想使用 Facebook iOS SDK 将我的 iOS 应用程序中的链接分享给登录我的应用程序的用户的个人朋友(同时让用户选择要分享给哪个朋友)。

回答by DSchultz

Our feed dialogs do not allow posting to another user's wall. To do this, I would suggest using our send dialogwhich allows the developer to specify the recipient user (end user can add additional users once the dialog is rendered).

我们的提要对话框不允许张贴到其他用户的墙上。为此,我建议使用我们的发送对话框,它允许开发人员指定收件人用户(一旦对话框呈现,最终用户可以添加其他用户)。

It can be rendered via the graph api as such:

它可以通过图形 API 呈现,如下所示:

https://www.facebook.com/dialog/send?app_id=123050457758183&
name=People%20Argue%20Just%20to%20Win&
link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&
redirect_uri=http://www.example.com/response

回答by Kevin Montag

As far as I know, the only place a dialog like that shows up is via the sharer.php endpoint, e.g. https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.stackoverflow.com. That endpoint appears to have been deprecated (there's a Quora threadabout it), but it's still functional for now.

据我所知,像这样的对话框出现的唯一地方是通过 sharer.php 端点,例如https://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.stackoverflow。 com. 该端点似乎已被弃用(有一个关于它的Quora 线程),但它现在仍然可以使用。

It's possible the sharer dialog used to be available as a UI method, but as far as I can tell that's no longer the case, so opening up sharer.php in your app is the only way to show those scoping options. It's clunky in mobile browsers, however - your custom friend picker followed by a feeddialog is arguably a more attractive solution.

共享器对话框可能曾经可用作 UI 方法,但据我所知,情况不再如此,因此在您的应用程序中打开 sharer.php 是显示这些范围选项的唯一方法。然而,它在移动浏览器中很笨拙 - 您的自定义朋友选择器后跟一个feed对话框可以说是一个更有吸引力的解决方案。