工作灯Facebook应用程序错误:“给定的URL是不允许的应用程序配置”

Worklight Facebook app error: "Given URL is not allowed by the Application configuration"

本文关键字:应用程序 URL 给定的 不允许 配置 Facebook 错误 工作      更新时间:2023-09-26

我遵循了这个教程:https://developers.facebook.com/docs/reference/javascript/#loading,这是我的IBM Worklight应用程序中的common/myapp.html中的代码:

<!DOCTYPE HTML>
<html xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
    <meta charset="UTF-8">
    <title>Buy3</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" href="images/favicon.png">
    <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
    <link rel="stylesheet" href="css/Buy3.css">
    <script>window.$ = window.jQuery = WLJQ;</script>
</head>
<body id="content" style="display: none;">
    <!--application UI goes here-->
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
  FB.init({
    appId      : 'xxxxx', // App ID
    channelUrl : 'http://stormy-sands-2143.herokuapp.com/channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true,  // parse XFBML
    oauth: true
  });

  };
  // Load the SDK asynchronously
   (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "http://connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);
   }(document));
  // Here we run a very simple test of the Graph API after login is successful. 
  // This testAPI() function is only called in those cases. 
  function testAPI() {
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Good to see you, ' + response.name + '.');
      //Log.i(TAG, "Logged in...");
    });
  }
</script>
<!--Below we include the Login Button social plugin. This button uses the JavaScript SDK to-->
<!--present a graphical Login button that triggers the FB.login() function when clicked.-->
<div id="user-info"></div>
<button id="fb-auth" onclick="FB.login();" >Login</button>
<script src="http://connect.facebook.net/en_US/all.js"></script>
    <script src="js/initOptions.js"></script>
    <script src="js/Buy3.js"></script>
    <script src="js/messages.js"></script>

</body>
</html>

以下是我的Facebook应用程序配置中的一些值:

App ID: "XXX"
Display Name: "[blah blah blah]"
Namespace: jfgjfgjhfgjh
App domains:stormy-sands-2143.herokuapp.com
HostingURL: https://stormy-sands-2143.herokuapp.com
Sandbox Mode: "Disable"
Site Url: http://stormy-sands-2143.herokuapp.com/
Canvas Page: http://apps.facebook.com/jfgjfgjhfgjh
Canvas URL: http://stormy-sands-2143.herokuapp.com/
Secure Canvas URL: https://stormy-sands-2143.herokuapp.com/
Page Tab URL: http://stormy-sands-2143.herokuapp.com/
Secure Page Tab URL: https://stormy-sands-2143.herokuapp.com/

注意,我必须改变js。SRC参数靠近教程中给出的示例代码的底部,与我的通道文件中的参数相同。

然后当我点击登录按钮,我看到facebook登录对话框,我已经把电子邮件和密码,然后点击确定,我有错误:

给定的URL不被应用程序配置允许。:一个或应用程序的设置不允许更多的给定url。它必须匹配网站URL或画布URL,或者域名必须是子域名

我在stackoverflow和google上搜索了所有内容,但无法解决此错误。谢谢你的帮助!

好了,只需删除关于heroku的所有内容,然后像这样配置app

App domains:localhost
HostingURL: 
Sandbox Mode: "Disable"
Site Url: http://localhost/
Canvas Page: http://apps.facebook.com/jfgjfgjhfgjh
Canvas URL: http://localhost/
Secure Canvas URL: https://localhost/
Page Tab URL: http://localhost/
Secure Page Tab URL: https://localhost/
然后

//channelUrl : 'http://stormy-sands-2143.herokuapp.com/channel.html'

在HTML

。如果有人需要的话