Jump to content

Facebook API...


Recommended Posts

Hey guy's im going nuts here trying to figure out how to make this login work...lol!


i get :

Response Exception: 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.


i added every combination URL possible in the section in the facebook dev app settings..


www no www / no /  root site members site localhost......


and when i refresh i get

SDK Exception: Cross-site request forgery validation failed. Required param "state" missing from persistent data.


so i tried for state issue:


in login $_SESSION['FBRLH_state']=$_GET['state'];  

	require_once "config.php";

	if (isset($_SESSION['access_token'])) {
		header('Location: index.php');
	$redirectURL = "https://".$_SERVER['SERVER_NAME']."/Meb/fb-callback.php";
	$permissions = ['email'];
	$loginURL = $helper->getLoginUrl($redirectURL, $permissions);
	//echo $redirectURL;
	//die($_SESSION['FBRLH_' . 'state']);
	$accessToken = $helper->getAccessToken()

My callback file:

	require_once "config.php";

	try {
		$accessToken = $helper->getAccessToken();
	} catch (\Facebook\Exceptions\FacebookResponseException $e) {
		echo "Response Exception: " . $e->getMessage();
	} catch (\Facebook\Exceptions\FacebookSDKException $e) {
		echo "SDK Exception: " . $e->getMessage();

	if (!$accessToken) {
		header('Location: login.php');

	$oAuth2Client = $FB->getOAuth2Client();
	if (!$accessToken->isLongLived())
		$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);

	$response = $FB->get("/me?fields=id,user_location, first_name, last_name, email, picture.type(large)", $accessToken);
	$userData = $response->getGraphNode()->asArray();
	$_SESSION['userData'] = $userData;
	$_SESSION['access_token'] = (string) $accessToken;
	header('Location: index.php');



	require_once "Facebook/autoload.php";

	$FB = new \Facebook\Facebook([
		'app_id' => 'MYID',
		'app_secret' => 'MYSECRET',
		'default_graph_version' => 'v2.11'

	$helper = $FB->getRedirectLoginHelper();

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.