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

荒凉一梦 提交于 2019-12-05 11:09:27
Mr.Geeker
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.

As originally answered here

On March 2018, facebook updated the API and forced all apps to keep strict mode On.

To make it work, you have to include the full callback url in the Valid OAuth Redirect URIs field. If you redirect to "https://www.example.com/facebook/callback", the full URI must be included (without parameters):

The domain must be set in the App domains and the Website Site URL fields on the basic settings page:

If none of these works and the "Can't Load URL: The domain of this URL isn't included in the app's domains." message keeps showing, check if you have the latest version of the SDK. I could make it work after updating de PHP SDK from version 5.5 to 5.6.2

I'm using PHP 5.5 and I found the 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:

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

The fixed can be done in the file Facebook/Helpers/ FacebookRedirectLoginHelper.php inside the getAccessToken function. I added a 'if' as below in the line 226 and the issue gone:

$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']);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!