Facebook Canvas:redirect_uri不归应用程序所有

时间:2013-04-07 03:48:18

标签: javascript facebook localhost facebook-canvas

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

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

1 个答案:

答案 0 :(得分:5)

您需要在“canvas url”中放置的网址可能是localhost:8080(应用网址由“名称空间”决定,并且始终为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>