应用程序配置不允许使用URL

1Ma*_*yur 61 configuration facebook-javascript-sdk facebook-social-plugins

我在我的html页面中使用过这个...

<script>     
window.fbAsyncInit = function() {
    // init the FB JS SDK
    FB.init({
      appId      : 'xxxxxxxxxxxxxx', // App ID from the App Dashboard
      status     : true, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });

    // Additional initialization code such as adding Event Listeners goes here
};

// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might 
// contain some type checks that are overly strict. 
// Please report such bugs using the bugs tool.
(function(d, debug){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
     ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));

 function shareOnFb(action, msg){
    FB.ui({ 
        method: action, 
        message: msg
    });
 }
</script>
Run Code Online (Sandbox Code Playgroud)

当我尝试调用任何FB方法时,它会在我的控制台中说出来

应用程序配置不允许使用URL:应用程序的设置不允许使用一个或多个给定的URL.它必须与网站URL或Canvas URL匹配,或者域必须是其中一个Apps域的子域.

这是我的fb app设置..我需要在这里改变一些东西,暂时在本地运行我的网站,所以我尝试添加

localhost/OfferDrive /到此页面上的应用程序域,但它说错误,它不是一个有效的域

fb app设置

Anv*_*ena 60

你需要填充Facebook登录网站的值,http://localhost/OfferDrive/以允许Facebook验证来自JavaScript SDK的请求来自正确的地方

  • "我不允许使用顶级域名" (4认同)

mun*_*llj 44

更新Anvesh Saxena的答案(正确但过时,因为FB App界面已更改):

在您的FB App配置中,您需要添加一个网站平台,其中包含您网站的URL集.然后,您可以添加我设置到我们网站的基本域的应用程序域(例如,对于像这样的URL http://www.mycoolwebsite.com,只需使用mycoolwebsite.com).

新的FB设置截图

重要提示:为了实现此目的,您需要使用应用程序URL的子域进行本地开发.您可以通过修改开发计算机上的hosts文件来轻松地执行此操作,以使用您网站中不存在的子域,例如local.mycoolwebsite.com.如果您不熟悉如何执行此操作,只需为您的平台(例如mac/windows)谷歌"编辑主机文件".


Dan*_*ald 18

设置 - >高级,将网址添加到"有效的OAuth重定向URI".这适合我.

  • 谢谢!为我工作,我添加了localhost和localhost:8100(进行离子开发) (3认同)

Luc*_*cky 9

  • 转到Facebook获取开发人员仪表板
  • 单击My Apps并从下拉列表中选择您的应用程序.
    (如果您尚未创建任何应用程序,请选择"添加新应用程序"以创建新应用程序).
  • 转到App Setting > Basic Tab然后单击底部的"添加平台".
  • 选择"网站"并添加网站以Site URL(例如mywebsite.com)登录
  • 如果您在本地进行测试,您甚至可以只提供应用的localhost URL.
    例如.http://localhost:8080/myfbsampleapp
  • 保存更改,您现在可以从中访问Facebook信息 http://localhost:8080/myfbsampleapp