Facebook Feed Dialog错误191

时间:2015-07-07 19:34:27

标签: javascript facebook dialog facebook-javascript-sdk facebook-feed

所以,我试图让Facebook Feed Dialog通过他们的API工作,但到目前为止还没有成功。

我使用Facebook Javascript SDK来完成它,以及FB.ui方法。

<script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'MY FB APP ID',
                xfbml      : true,
                version    : 'v2.3'
            });
        };

        (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/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>

    <script type="text/javascript">
        function fbShare(url, title, descr, image) {
            FB.ui({
                method: 'feed',
                name: title,
                link: url,
                caption: 'Title',
                description: descr,
                picture: image,
                display: 'popup',
                redirect_uri: url
            },
            function(response) {
                if (response && response.post_id) {
                    //alert('Post was published.');
                } else {
                    //alert('Post was not published.');
                }
            });
        }
    </script>

这就是我的链接:

<a href="javascript:fbShare('http://mywebsite.com/avaliacao/9d8ee3cb3ad759b134da94802e7c49c8', 'My Site Has a new share', 'Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.', 'http://mywebsite.com.br/img/fb-share.png')">Share</a>

单击共享链接时出现的错误:

  

发生错误。请稍后再试。

     

API错误代码:191   API错误说明:指定的URL不属于应用程序   错误消息:redirect_uri不归应用程序所有。&#34;

2 个答案:

答案 0 :(得分:0)

删除redirect_url,然后重试。或者确保在应用设置(http://mywebsite.com/)中添加redirect_url网站平台的域名。

答案 1 :(得分:0)

我以另一种方式结束使用Feed对话框。

Javascript:

<script type="text/javascript">
function fbShare(url, title, descr, image, winWidth, winHeight) {
    var winTop = (screen.height / 2) - (winHeight / 2);
    var winLeft = (screen.width / 2) - (winWidth / 2);
    window.open('https://www.facebook.com/dialog/feed?app_id=APP-ID
        &name=' + title
        + '&picture=' + image
        + '&caption=My+Caption
        &display=popup' + '
        &description=' + descr + '
        &link=' + url + '
        &redirect_uri=http://mywebsite.com.br/fb-close-popup-window',
        'sharer',
        'top=' + winTop + ',
        left=' + winLeft + ',
        toolbar=0,
        status=0,
        width=' + winWidth + ',
        height=' + winHeight);
}
</script>

HTML

<a href="javascript:fbShare('http://mywebsite.com/9d8ee3cb3ad759b134da94802e7c49c8','My Site Has a new share','Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content.','http://mywebsite.com.br/img/fb-share.png',520, 350)">Share</a>