FB.ui返回错误:元素未指定



使用来自开发人员站点的示例:

FB.ui(
  {
    method: 'feed',
    name: 'Facebook Dialogs',
    link: 'https://developers.facebook.com/docs/reference/dialogs/',
    picture: 'http://fbrell.com/f8.jpg',
    caption: 'Reference Documentation',
    description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
  },
  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

得到的结果如下:

Error: element not specified
innerError: undefined
message: "element not specified"

一开始我以为我错过了"fb-root"元素,但我在我的身体里有它:

<body onLoad="onLoad()">
    <div id="fb-root"></div>
</body>

现在我认为这与我的主干/jQuery移动使用有关,因为一旦加载第一页,body就会被清除。然而,FB对象是加载的,所以我真的不知道什么是错误的。有什么办法可以解决这个问题吗?

谢谢。

我有同样的问题,我发现这是发生在Chrome。您使用的是哪种浏览器?对我有用的是指定

display: 'popup'

在FB。ui {}

此刻我检查浏览器,如果Chrome我使用'弹出',如果不是'iframe'

  var display = 'iframe';
  if (navigator.userAgent.toLowerCase().indexOf("chrome") != -1){
          display = "popup"
  }
  FB.ui({
        method: 'share',
        display: display,
        href: 'https://developers.facebook.com/docs/reference/dialogs/'
        },
   function (response) {}
  );

应该也工作与饲料,但我还没有测试它。

最新更新