I wanted to have a Facebook and Google login button on my website and found a website with a project like that: http://www.smarttutorials.net/oauth-login-for-facebook-twitter-and-google-plus-using-php/
The google login seems to be working fine but the facebook one brings me to the facebook page where I have to login but when I click on login it redirects me to a white page with no errors. This is the facebook code that's apparently causing the blank page:
FacebookSession::setDefaultApplication(FB_APP_ID, FB_APP_SECRET);
$helper = new FacebookRedirectLoginHelper(FB_REDIRECT_URI);
if(isset($_GET['type']) && $_GET['type'] == 'facebook' ){
$fb_url = $helper->getLoginUrl(array('email'));
header('Location: ' . $fb_url);
}
$session = $helper->getSessionFromRedirect();
if(isset($_SESSION['token'])){
$session = new FacebookSession($_SESSION['token']);
try{
$session->validate(FB_APP_ID, FB_APP_SECRET);
}catch(FacebookAuthorizationException $e){
echo $e->getMessage();
}
}
$data = array();
if(isset($session)){
$_SESSION['token'] = $session->getToken();
$request = new FacebookRequest($session, 'GET', '/me');
$response = $request->execute();
$graph = $response->getGraphObject(GraphUser::className());
$data = $graph->asArray();
$id = $graph->getId();
$image = "https://graph.facebook.com/".$id."/picture?width=100";
$data['image'] = $image;
if($user_obj->fb_login($data)){header('Location: home.php');}
else{header('Location: index.php');}
}
The code is apparently from like 2 years ago so maybe that's why, but I can't seem to make it work. Does anyone have an idea what could be wrong with the code?