javascript - Facebook Canvas : redirect_uri is not owned by the application

标签 javascript facebook localhost facebook-canvas

我正在尝试将 facebook canvas 集成到当前在 localhost:8080 上运行的 Web 应用程序上 运行该网站时,它给了我这个错误。

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.

这是我的应用程序设置。

enter image description here

我只是按照文档进行操作,然后出现了此错误,

window.fbAsyncInit = function() {
                            FB
                                    .init({
                                        appId : 'myappIdHere', // App ID
                                        channelUrl : 'https://apps.facebook.com/mytestapp/', // Channel File
                                        status : true, // check login status
                                        cookie : true, // enable cookies to allow the server to access the session
                                        xfbml : true
                                    // parse XFBML
                                    });
                            FB.ui({
                                method : 'feed'
                            });
                        };
                        // Load the SDK Asynchronously
                        (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'));

最佳答案

您需要放置在“canvas url”中的 URL 可能是 localhost:8080(应用程序 URL 由“ namespace ”确定,并且始终为 http://apps.facebook.com/namespace (这对于您的应用程序来说必须是唯一的。)

您需要指定一个重定向 URI http://developers.facebook.com/docs/reference/dialogs/feed/

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

  function postToFeed() {

    // calling the API ...
    var obj = {
      method: 'feed',
      redirect_uri: 'https://apps.facebook.com/mytestapp/',
      link: 'https://apps.facebook.com/mytestapp/',
      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'];
    }

    FB.ui(obj, callback);
  }

</script>

关于javascript - Facebook Canvas : redirect_uri is not owned by the application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15858662/

相关文章:

javascript - React 的状态如何通过使用扩展运算符来保存文件?

objective-c - 我们可以邀请人们使用我们的应用程序或通过 iOS 5 中的 Facebook 从应用程序发送好友请求吗?

java - RestFB:Facebook HTTP 400 错误不够具体

apache - HBase master 无法启动,无法连接到 hbase.rootdir

php - 使用 XAMPP 设置 $_SESSION 在本地主机上不起作用

macos - 在网络 PC 上查看 Mac Localhost

javascript - 在格式化数字后将插入符设置回原来的位置

javascript - 每个元素的 jQuery 动画

javascript - 使用 Jasmine 测试 DOM 操作

ios - 在 Facebook 页面上发布视频