0

目标

通过 Facebook 的墙分享一张简单的图片。

问题

FB 的 API 错误

或者,如果有一天图像离线:

API 错误代码:191

API 错误描述:指定的 URL 不属于应用程序

错误消息:redirect_uri 不属于应用程序。


我的问题是:我做错了什么?

场景

首先,我加载 Facebook 的 JavaScript SDK:

<script type="text/javascript">
    window.fbAsyncInit = function() {
        FB.init({
            appId: 'xxx',
            channelUrl: '//localhost/channel.html',
            status: true,
            xfbml: true
        });
    };

    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {
            return;
        }
        js = d.createElement(s);
        js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

其次,我的应用程序上有以下按钮:

<a href="#" onClick="publishOnFacebook()">
    <i class="icons icon-facebook-big"></i></a>

publishOnFacebook()方法是:

function publishOnFacebook() {
    FB.ui(
        {
            method: 'feed',
            name: 'Facebook Dialogs',
            link: 'https://developers.facebook.com/docs/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.');
            }
        }
    );
}

最后,这是我的应用程序:

我在 Facebook 上的申请

4

1 回答 1

2

尝试类似以下的操作。

<script type="text/javascript">
function publishOnFacebook() {
FB.ui(
  {
    method: 'feed',
    name: 'Facebook Dialogs',
    link: 'http://localhost/',
    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.');
    }
  }
);
}
</script>

<a href="#" onClick="publishOnFacebook()">
    <i class="icons icon-facebook-big"></i></a>
于 2013-09-16T15:50:42.807 回答