简体   繁体   English

Facebook App - 此URL的域名未包含在应用程序的域中。 为什么?

[英]Facebook App - The domain of this URL isn't included in the app's domains. Why?

When trying to login with a Facebook app, I'm getting the following error: 当尝试使用Facebook应用程序登录时,我收到以下错误:

Can't Load URL: The domain of this URL isn't included in the app's domains. 无法加载网址:此网址的域名未包含在应用的域中。 To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings. 要加载此网址,请将应用的所有域和子域添加到应用设置中的应用域名字段中。

As you can see on the following image: 如下图所示:

在此输入图像描述

URL: http://www.facebook-php-test.com 网址: http//www.facebook-php-test.com

Below is the configuration I have set on my Facebook App. 以下是我在Facebook App上设置的配置。

( Notice: for privacy purposes I changed the values for App ID and App Secret on the image) 注意:出于隐私目的,我在图像上更改了App IDApp Secret的值)

在此输入图像描述

The code for this basic sample application is on this GitHub repository: 此基本示例应用程序的代码位于此GitHub存储库中:

https://github.com/zeuscronos/facebook-php-test.com https://github.com/zeuscronos/facebook-php-test.com

I really don't know why it says that the domain of this URL isn't included in the app's domains when it is actually there. 我真的不知道为什么它说the domain of this URL isn't included in the app's domains实际上并the domain of this URL isn't included in the app's domains

On the field: App Domains I tried with both domains at the same time: 在该字段: App Domains我同时尝试使用这两个域:

  • facebook-php-test.com facebook-php-test.com
  • www.facebook-php-test.com www.facebook-php-test.com

but no success. 但没有成功。

The generated login URL is as follows: 生成的登录URL如下:

https://www.facebook.com/v2.10/dialog/oauth?client_id=012345678901234&state=d3758e484d539bebd6505427aaf1fa3b&response_type=code&sdk=php-sdk-5.6.1&redirect_uri=http%3A%2F%2Fwww.facebook-php-test.com%2Ffb-callback.php&scope=email%2Cuser_friends%2Cuser_photos https://www.facebook.com/v2.10/dialog/oauth?client_id=012345678901234&state=d3758e484d539bebd6505427aaf1fa3b&response_type=code&sdk=php-sdk-5.6.1&redirect_uri=http%3A%2F%2Fwww.facebook-php-test.com% 2Ffb-callback.php&范围=电子邮件%2Cuser_friends%2Cuser_photos

I configured the domain: facebook-php-test.com as a virtual host on an Apache server. 我将域名: facebook-php-test.com配置为Apache服务器上的虚拟主机。

I have to say that I have worked a lot with the Facebook PHP SDK and this is the first time I'm getting struggle with this. 我不得不说我在Facebook PHP SDK做了很多工作,这是我第一次遇到这个问题。 Actually, I got this problem with another big application I was working with then after couple of hours trying to solve the problem I created this dummy application to try to figure out what's the cause of the problem. 实际上,我遇到了另一个我正在使用的大应用程序的问题,然后经过几个小时试图解决问题我创建了这个虚拟应用程序,试图弄清问题的原因是什么。

I have tried many things with no success. 我尝试过很多事情都没有成功。

Any idea on how to solve this? 关于如何解决这个问题的任何想法?

Thanks. 谢谢。

EDIT 01 编辑01

Following the suggestion of Mr.Geeker comment I did the following... 根据Mr.Geeker评论的建议,我做了以下......

Added the product: Facebook Login and configured like below: 添加产品: Facebook Login并配置如下:

在此输入图像描述

Then, finally I could go forward, and I was asked for permissions: 然后,最后我可以继续前进,并且我被要求获得权限:

在此输入图像描述

But unfortunately, after granting permissions, I got the following: 但遗憾的是,在授予权限后,我得到了以下内容:

在此输入图像描述

Any idea on how to continue from this point? 关于如何从这一点继续的任何想法?

EDIT 02 - SOLUTION 编辑02 - 解决方案

I ended disabling the option: Use Strict Mode for Redirect URIs under Client OAuth Settings . 我结束了禁用该选项:在Client OAuth SettingsUse Strict Mode for Redirect URIs They say it is strongly recommended has this feature On but I could not get this working with that On . 他们说,这是strongly recommended有此功能On ,但我不能得到这个工作,与On

By the way I also disabled: Client OAuth Login since my app doesn't use it. 顺便说一句,我也禁用了: Client OAuth Login因为我的应用程序不使用它。

Finally, the only feature I have enable under: Client OAuth Settings is: Web OAuth Login . 最后,我启用的唯一功能是: Client OAuth Settings是: Web OAuth Login

Facebook now roles some features as plugins. Facebook现在将一些功能作为插件。 In the left hand side select Products and add product. 在左侧选择产品并添加产品。 Then select Facbook Login. 然后选择Facbook Login。 Pretty straight forward from there, you'll see all the Oauth options show up. 从那里很直接,你会看到所有的Oauth选项出现。

As originally answered here 最初在这里回答

On March 2018, facebook updated the API and forced all apps to keep strict mode On. 在2018年3月,Facebook更新了API并强制所有应用程序保持严格模式。

To make it work, you have to include the full callback url in the Valid OAuth Redirect URIs field. 要使其工作,您必须在Valid OAuth Redirect URIs字段中包含完整的回调URL。 If you redirect to " https://www.example.com/facebook/callback ", the full URI must be included (without parameters): 如果您重定向到“ https://www.example.com/facebook/callback ”,则必须包含完整的URI(不带参数):

在此输入图像描述

The domain must be set in the App domains and the Website Site URL fields on the basic settings page: 必须在基本设置页面上的应用程序域和网站站点URL字段中设置域:

在此输入图像描述

If none of these works and the "Can't Load URL: The domain of this URL isn't included in the app's domains." 如果这些都不起作用并且“无法加载URL:此URL的域未包含在应用程序的域中”。 message keeps showing, check if you have the latest version of the SDK . 消息不断显示, 检查您是否拥有最新版本的SDK I could make it work after updating de PHP SDK from version 5.5 to 5.6.2 从版本5.5到5.6.2更新de PHP SDK后,我可以使它工作

I'm using PHP 5.5 and I found the bug. 我正在使用PHP 5.5,我发现了这个bug。

The PHP Facebook API VERSION = '5.5.0', DEFAULT_GRAPH_VERSION = 'v2.9' was adding the URI ?code=XXX in my callback page like this: PHP Facebook API VERSION ='5.5.0',DEFAULT_GRAPH_VERSION ='v2.9'在我的回调页面中添加了URI ?code = XXX ,如下所示:

mydomainExample.com/callbackFacebook.php ?code=XXXXXXX mydomainExample.com/callbackFacebook.php?code = XXXXXXX

and I changed the source code to remove the string after '?'. 然后我更改了源代码以删除'?'后面的字符串。 Now the callback url is only 现在回调网址只是

mydomainExample.com/callbackFacebook.php mydomainExample.com/callbackFacebook.php

The fixed can be done in the file Facebook/Helpers/ FacebookRedirectLoginHelper.php inside the getAccessToken function. 修复可以在getAccessToken函数内的文件Facebook / Helpers / FacebookRedirectLoginHelper.php中完成 I added a ' if ' as below in the line 226 and the issue gone: 我在第226行添加了一个' if '如下,问题消失了:

$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();

//the next 3 lines was added to avoid the bug (fixed)
if(strripos($redirectUrl, "?")){
  $redirectUrl = substr($redirectUrl, 0, strripos($redirectUrl, "?"));
}

// At minimum we need to remove the state param
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state']);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载 URL:此 URL 的域未包含在应用程序的域中。 为了能够加载这个 URL... Codeigniter - Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL… Codeigniter Facebook 显示错误:无法加载 URL:此 URL 的域未包含在应用程序的域中 - Facebook showing error: Can't Load URL: The domain of this URL isn't included in the app's domains Facebook Auth:无法加载URL:此URL的域未包含在应用的域中 - Facebook Auth: Can't Load URL: The domain of this URL isn't included in the app's domains facebook登录名:无法加载URL:该URL的域未包含在应用程序的域中 - facebook login : Can't Load URL: The domain of this URL isn't included in the app's domains Facebook身份验证,严格的OAuth模式:此URL的域不包含在应用程序的域中 - Facebook Authentication, Strict OAuth Mode: The domain of this URL isn't included in the app's domains 图表返回错误:无法加载网址:此网址的域未包含在应用的域中 - Graph returned an error: Can't Load URL: The domain of this URL isn't included in the app's domains Facebook登录:该应用程序的域中未包含URL! 我收到错误> FacebookClient.php中的可捕获致命错误 - Facebook Login: URL isn't included in the app's domains! I get error > Catchable fatal error in FacebookClient.php 无法加载网址:此网址的域未包含在应用程序的域中 - Unable to load URL: This URL's domain is not included in the app's domain 使用Facebook App的Muti级域名 - Muti level domains with Facebook App 为什么连接Facebook应用程序返回混淆URL - why connect facebook app return confuse URL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM