【问题标题】:How to share a simple image on Facebook (with Callback)? [duplicate]如何在 Facebook 上分享一张简单的图片(带有回调)? [复制]
【发布时间】:2013-09-16 15:07:37
【问题描述】:

目标

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

问题

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

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.');
            }
        }
    );
}

最后,这是我的应用:

【问题讨论】:

  • redirect_uri 更改为 Facebook in-front(后备适用于任何应用程序)并且您尝试共享的链接 link: 'https://developers.facebook.com/docs/dialogs/' 不是您在设置中指定的应用程序域尝试将其更改为http://localhost/myHTMl.html
  • 我应该在哪里更改 redirect_uri 的建议,@AdamZapp?
  • redirect_uri 在应用设置中是Site Url

标签: javascript facebook


【解决方案1】:

试试下面的方法。

<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-11-25
  • 1970-01-01
  • 1970-01-01
  • 2020-08-13
  • 2017-10-19
  • 1970-01-01
  • 2018-10-06
  • 2013-06-12
  • 1970-01-01
相关资源
最近更新 更多