techker Posted May 17, 2018 Share Posted May 17, 2018 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'); exit(); } $_SESSION['FBRLH_state']=$_GET['state']; $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: session_start(); require_once "config.php"; try { $accessToken = $helper->getAccessToken(); } catch (\Facebook\Exceptions\FacebookResponseException $e) { echo "Response Exception: " . $e->getMessage(); exit(); } catch (\Facebook\Exceptions\FacebookSDKException $e) { echo "SDK Exception: " . $e->getMessage(); exit(); } if (!$accessToken) { header('Location: login.php'); exit(); } $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'); exit(); config: session_start(); require_once "Facebook/autoload.php"; $FB = new \Facebook\Facebook([ 'app_id' => 'MYID', 'app_secret' => 'MYSECRET', 'default_graph_version' => 'v2.11' ]); $helper = $FB->getRedirectLoginHelper(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.