使用FB.ui的Facebook Feed对话框给出了API错误191

时间:2012-09-09 10:03:16

标签: javascript facebook api mobile

我想在我的网站上添加一个自定义的Facebook分享按钮,就像你在BBC新闻报道的顶部看到的那样,如http://www.bbc.co.uk/news/uk-19535236。他们正在使用Facebook Feed对话框。因此,当您点击该链接时,您会看到一个对话框,允许您将您所在页面的网址发布到您的时间轴。

FB.ui方法似乎是调用对话框的最佳方式,因为它会自动为您的设备创建正确类型的弹出窗口。因此,使用手机的人会看到一个适合他们设备的弹出窗口。此方法还允许我们指定回调,因此一旦用户共享链接,我们就可以增加他们共享的页面上的共享计数。

我正在尝试关注http://developers.facebook.com/docs/reference/dialogs/feed/上的第一个例子。

<div id='fb-root'></div>

<script src='http://connect.facebook.net/en_US/all.js'></script>

<p><a href="#" onclick='postToFeed(); return false;'>Post to Feed</a></p>

<p id='msg'></p>

<script>
    FB.init({appId: "00000000000", status: true, cookie: true});

    function postToFeed() {

        // calling the API ...
        var obj = {
            method: 'feed',
            link: 'http://example.com/',
            picture: 'http://fbrell.com/f8.jpg',
            name: 'Facebook Dialogs',
            caption: 'Reference Documentation',
            description: 'Using Dialogs to interact with users.'
        };

        function callback(response) {
            document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
            if (response && response.post_id) {
                alert('Post was published.');
            } else {
                alert('Post was not published.');
            }
        }

        FB.ui(obj, callback);

    }

</script>

(将我的实际app_id替换为00000000000和http://example.com/的网站网址)。但是当我点击链接时出现此错误:

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.

即使'link'参数与我的Facebook应用设置中的应用的“网站网址”完全匹配,我也明白这一点。

谁能告诉我如何才能让它发挥作用?我希望人们能够在我的网站上共享任何页面,而不仅仅是与我的Facebook应用程序对应的URL。

1 个答案:

答案 0 :(得分:3)

为了共享工作,应用程序配置的最低要求是设置至少

应用域名(在基本信息下)

网站网址(在Facebook登录网站下)

App Domains : example.com
Site URL : http://example.com

设置其他参数也可以像移动网站网址

一样工作
相关问题