0

我遵循了本教程: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 上搜索了所有内容,但无法解决此错误。谢谢你的帮助!

4

1 回答 1

1

好的,我知道了,只需删除有关 heroku 的所有内容,然后像这样的应用程序配置

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 中。对于任何需要它的人

于 2013-05-17T09:50:39.700 回答