Facebook 应用程序 - 此 URL 的域未包含在该应用程序的域中。为什么?
Facebook App - The domain of this URL isn't included in the app's domains. Why?
尝试使用 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.
如下图所示:
URL: http://www.facebook-php-test.com
以下是我在 Facebook 应用程序上设置的配置。
(注意: 出于隐私目的,我更改了图像上 App ID
和 App Secret
的值)
此基本示例应用程序的代码位于此 GitHub 存储库中:
https://github.com/zeuscronos/facebook-php-test.com
我真的不知道为什么它说 the domain of this URL isn't included in the app's domains
其实它在那里。
现场:App Domains
我同时尝试了两个域:
- facebook-php-test.com
- www.facebook-php-test.com
但没有成功。
生成的登录URL如下:
我配置域:facebook-php-test.com
作为 Apache 服务器上的虚拟主机。
我不得不说,我在 Facebook PHP SDK
方面做了很多工作,这是我第一次遇到这个问题。实际上,我在使用另一个大型应用程序时遇到了这个问题,然后在尝试解决问题几个小时后,我创建了这个虚拟应用程序以试图找出问题的原因。
我试过很多东西都没有成功。
知道如何解决这个问题吗?
谢谢。
EDIT 01
根据 Mr.Geeker
评论的建议,我做了以下...
添加了产品:Facebook Login
并配置如下:
然后,终于可以继续了,我被要求权限:
但不幸的是,在授予权限后,我得到了以下信息:
知道如何从现在开始继续吗?
EDIT 02 - SOLUTION
我结束了禁用选项:Client OAuth Settings
下的 Use Strict Mode for Redirect URIs
。他们说 strongly recommended
具有此功能 On
但我无法使用 On
.
顺便说一下,我还禁用了:Client OAuth Login
因为我的应用程序不使用它。
最后,我在 Client OAuth Settings
下启用的唯一功能是:Web OAuth Login
.
Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.
最初的回答
2018 年 3 月,Facebook 更新了 API 并强制所有应用程序保持严格模式。
要使其正常工作,您必须在有效 OAuth 重定向 URI 字段中包含完整回调 url。如果重定向到“https://www.example.com/facebook/callback”,则必须包含完整的 URI(不带参数):
必须在基本设置页面的应用域和网站站点 URL 字段中设置域:
如果 none 这些工作正常并且 "Can't Load URL: The domain of this URL isn't included in the app's domains." 消息一直显示,检查您是否有最新版本的 SDK。将 de PHP SDK 从版本 5.5 更新到 5.6.2
后,我可以让它工作
我正在使用 PHP 5.5,我发现了这个错误。
PHP Facebook API VERSION = '5.5.0',DEFAULT_GRAPH_VERSION = 'v2.9' 正在添加 URI ?code=XXX 在我的回调页面中是这样的:
mydomainExample.com/callbackFacebook.php ?code=XXXXXXX
并且我更改了源代码以删除“?”之后的字符串。现在回调 url 只有
mydomainExample.com/callbackFacebook.php
修复可以在 Facebook/Helpers/ FacebookRedirectLoginHelper.php 文件中 getAccessToken 函数中完成。我在第 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']);
尝试使用 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.
如下图所示:
URL: http://www.facebook-php-test.com
以下是我在 Facebook 应用程序上设置的配置。
(注意: 出于隐私目的,我更改了图像上 App ID
和 App Secret
的值)
此基本示例应用程序的代码位于此 GitHub 存储库中:
https://github.com/zeuscronos/facebook-php-test.com
我真的不知道为什么它说 the domain of this URL isn't included in the app's domains
其实它在那里。
现场:App Domains
我同时尝试了两个域:
- facebook-php-test.com
- www.facebook-php-test.com
但没有成功。
生成的登录URL如下:
我配置域:facebook-php-test.com
作为 Apache 服务器上的虚拟主机。
我不得不说,我在 Facebook PHP SDK
方面做了很多工作,这是我第一次遇到这个问题。实际上,我在使用另一个大型应用程序时遇到了这个问题,然后在尝试解决问题几个小时后,我创建了这个虚拟应用程序以试图找出问题的原因。
我试过很多东西都没有成功。
知道如何解决这个问题吗?
谢谢。
EDIT 01
根据 Mr.Geeker
评论的建议,我做了以下...
添加了产品:Facebook Login
并配置如下:
然后,终于可以继续了,我被要求权限:
但不幸的是,在授予权限后,我得到了以下信息:
知道如何从现在开始继续吗?
EDIT 02 - SOLUTION
我结束了禁用选项:Client OAuth Settings
下的 Use Strict Mode for Redirect URIs
。他们说 strongly recommended
具有此功能 On
但我无法使用 On
.
顺便说一下,我还禁用了:Client OAuth Login
因为我的应用程序不使用它。
最后,我在 Client OAuth Settings
下启用的唯一功能是:Web OAuth Login
.
Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.
最初的回答
2018 年 3 月,Facebook 更新了 API 并强制所有应用程序保持严格模式。
要使其正常工作,您必须在有效 OAuth 重定向 URI 字段中包含完整回调 url。如果重定向到“https://www.example.com/facebook/callback”,则必须包含完整的 URI(不带参数):
必须在基本设置页面的应用域和网站站点 URL 字段中设置域:
如果 none 这些工作正常并且 "Can't Load URL: The domain of this URL isn't included in the app's domains." 消息一直显示,检查您是否有最新版本的 SDK。将 de PHP SDK 从版本 5.5 更新到 5.6.2
后,我可以让它工作我正在使用 PHP 5.5,我发现了这个错误。
PHP Facebook API VERSION = '5.5.0',DEFAULT_GRAPH_VERSION = 'v2.9' 正在添加 URI ?code=XXX 在我的回调页面中是这样的:
mydomainExample.com/callbackFacebook.php ?code=XXXXXXX
并且我更改了源代码以删除“?”之后的字符串。现在回调 url 只有
mydomainExample.com/callbackFacebook.php
修复可以在 Facebook/Helpers/ FacebookRedirectLoginHelper.php 文件中 getAccessToken 函数中完成。我在第 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']);