Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graph returned an error: Can't Load URL: The domain of this URL isn't included in the app's domains

Added domain in App Domains, Valid OAuth redirect URIs also added.. but, Getting error message like this I have done my best... Anybody help me... it was quite irritating, I'm loosing my patience and getting panic. I really don't know, what is my big mistake in this. See this following images to know more about my problem

Image 1

Image 2

like image 475
Dara Naveen Kumar Avatar asked Feb 23 '17 11:02

Dara Naveen Kumar


People also ask

How do you solve the can't load URL the domain of this URL isn't included in the app's domains Facebook login error?

The exact error message is: 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 sub-domains of your app to the App Domains field in your app settings. Click Save Changes.

How do you add a domain to the Facebook app?

Before you enter your domain, first click on Add Platform, select website, enter your site URL and mobile site url. Save the settings. Thereafter, you can enter the domain name in the App domains field.

How do I change my callback URL on Facebook app?

In the "Facebook Login" tab under your app, enter all valid callback URL's, such as http://localhost/callback, http://productionUrl/callback, etc. If you don't see "Facebook Login" tab under your app, click "Add Product-> Facebook Login->Get Started" Enter the Valid Callback Urls -> Save changes.


2 Answers

We have 3 ways to fix it

1) Turn Off

Use Strict Mode for Redirect URIs

in Facebook Login-> Settings

2)

$accessToken = $helper->getAccessToken();

to

$accessToken = $helper->getAccessToken('https://example.com/your-CallBack-URI-page.php');

3) This is fine for development purpose when you don't want to waste time, for production use

session_start();
require_once __DIR__ . '/vendor/autoload.php';

$fb = new Facebook\Facebook([
  'app_id' => 'appid',
  'app_secret' => 'app secret',
  'default_graph_version' => 'v2.6 ', 
  "persistent_data_handler"=>"session"
  ]);
$helper = $fb->getRedirectLoginHelper();
$permissions = ['email']; // optional

$loginUrl = $helper->getLoginUrl('domain.com/php-graph-sdk-5.x/login-callback.php/', $permissions);
$_SESSION['FBRLH_state']=$_GET['state'];
try {
  $accessToken = $helper->getAccessToken('domian.com/php-graph-sdk-5.x/login-callback.php/');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
like image 181
Omkar Frozen Avatar answered Nov 22 '22 18:11

Omkar Frozen


From march the strict mode will be forced as enable. If you have any query parameters to your redirect url they should be included in the state parameter.

For details check my answer to a similar post.

like image 21
chess4ever Avatar answered Nov 22 '22 18:11

chess4ever