-1

所以,我试图让 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 不属于应用程序。”

4

2 回答 2

0

删除并重redirect_url试。或者确保在应用设置 ( http://mywebsite.com/ )中添加redirect_urlas Website 平台的域。

于 2015-07-07T21:09:46.103 回答
0

我结束了使用另一种方式来使用提要对话框。

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>
于 2015-07-08T13:57:58.793 回答