在本地的Facebook应用程序开发中我做错了什么? [英] What am I doing wrong in localhost Facebook app development?

查看:108
本文介绍了在本地的Facebook应用程序开发中我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

App Domains: localhost
Website with Facebook login: http://localhost/auth

我去 http:// localhost / auth / ,在我的Chrome开发者控制台中,我看到错误:应用程序配置不允许给定URL:应用程序设置不允许一个或多个给定的URL。它必须与网站网址或画布网址相匹配,否则域名必须是应用程序域名之一的子域名。

I go to http://localhost/auth/ and in my Chrome developer console I see the error: Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

我做了一个视图-source来查看以下内容:

I do a view-source to see the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div id="fb-root"></div>
<script>
  // Additional JS functions here
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'myappidremovedfromstackoverflowquestion', // App ID
      channelUrl : '//localhost/auth/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
    });

    // Additional init code here

  };

  // Load the SDK Asynchronously
  (function(d){
     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.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>
<p>hello</p>
</body>
</html>

我去 http://localhost/auth/channel.html 并查看源代码以查看单行:

I go to http://localhost/auth/channel.html and view source to see the single line:

<script src="//connect.facebook.net/en_US/all.js"></script>


推荐答案

当您想连接时,您应该使用一些别名域您的Facebook应用程序与您当地的环境。

You should use some alias domain when you want to connect your Facebook application with your local environment.

尝试以下操作:


  1. p>转到您的 etc / hosts (或%systemroot%/ system32 / drivers / etc / hosts )文件,添加以下行:
  1. Go to your etc/hosts (or %systemroot%/system32/drivers/etc/hosts) file and add the following line:

127.0.0.1 foo.local#alias domain

转到 App>设置并通过简单地使用 foo.local 作为应用程序域注册您的应用程序。

Go to App > Settings and register your application by simply using foo.local as app domain.

添加您的网站网址(例如 http:// foo.local / project /

Add your Site URL (e.g. http://foo.local/project/ )

完成

在16.01.2016修改:

Facebook已经改变了他们的用户界面,按照这些步骤使其工作。

Facebook has changed their UI, follow these steps to make it works.


  1. 转到 App>设置>基本(标签)

  2. 点击添加平台,选择网站并输入您的别名域名。

  3. App Domain 部分添加您的域名。

  4. 完成

  1. Go to App > Settings > Basic (tab)
  2. Click on Add Platform, select "Website" and enter your alias domain.
  3. Add your domain in App Domain section.
  4. Done.

这篇关于在本地的Facebook应用程序开发中我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆