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

时间:2013-01-23 07:00:39

标签: 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>

当我尝试调用任何FB方法时,它会在我的控制台中说明这一点

  

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

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

  在此页面上

localhost / OfferDrive /到应用程序域,但是它表示它不是有效域的错误

fb app settings

10 个答案:

答案 0 :(得分:60)

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

答案 1 :(得分:44)

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

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

New FB Settings Screenshot

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

答案 2 :(得分:18)

设置 - &gt;高级,将网址添加到&#34;有效的OAuth重定向URI&#34;。这对我有用。

答案 3 :(得分:9)

  • 转到Facebook for developers dashboard
  • 点击My Apps,然后从下拉列表中选择您的应用。
    (如果您还没有创建任何应用,请选择&#34;添加新应用&#34;创建新应用)。
  • 转到App Setting > Basic Tab,然后点击&#34;添加平台&#34;在底部。
  • 选择&#34;网站&#34;并添加网站以Site URL(例如mywebsite.com
  • 登录
  • 如果您在本地进行测试,您甚至可以只提供应用的本地主机URL 例如。 http://localhost:8080/myfbsampleapp
  • 保存更改,您现在可以从http://localhost:8080/myfbsampleapp
  • 访问Facebook信息

答案 4 :(得分:2)

更新munsellj的更新..

我在开发过程中只需将localhost:3000添加到&#39;网站网址&#39;选项并将“应用程序域”框留空。 正如munsellj所提到的那样,请确保您已经添加了一个网站平台。

答案 5 :(得分:2)

  1. 从位于左上角的应用名称的菜单项中,创建一个测试应用。
  2. 在新测试应用的设置部分:将“http://localhost:3000”添加到网站网址,并将“localhost”添加到应用域。
  3. 使用新的Facebook APP Id
  4. 更新您的应用
  5. 使用Facebook sdk v2.2或您应用中的最新内容。

答案 6 :(得分:1)

注意, localhost 是FB允许的特殊字符串。如果您没有在localhost下配置调试环境,那么就我所知,你必须将它推到该名称下面。

答案 7 :(得分:1)

有时旧的javascript sdk会出现此错误。如果您保存本地javascript文件。更新它。我更喜欢一直从facebook服务器加载它。

答案 8 :(得分:1)

缺少其他答案是如何允许localhost(或0.0.0.0或其他)作为oauth回调网址。这是解释。 How can I add localhost:3000 to Facebook App for development

答案 9 :(得分:1)

这种情况可能发生的另一个原因是你发送了错误的appId。如果您有开发应用程序和生产应用程序,这可能会在早期开发中发生。如果您对dev的appId进行硬编码并推送到prod,则会显示。