'session' property below */ session_start(); /** * you should update these values when debugging, * NOTE website URL for the app must be be set to http://localhost:8000/ */ $fb = new Facebook\Facebook(array( 'app_id' => '460287924057084', 'app_secret' => 'e27a5a07f9f07f52682d61dd69b716b5', 'default_graph_version' => 'v2.5', 'persistent_data_handler' => 'session' )); $helper = $fb->getRedirectLoginHelper(); $permissions = []; //after logging in facebook will redirect us to this callback page $callback = 'http://localhost:8000/facebook'; try { $accessToken = $helper->getAccessToken(); if ($accessToken) { //if everything is ok we have accessToken from the callback $response = $fb->get('/me', $accessToken); $user = $response->getGraphUser()->asArray(); $logoutUrl = $helper->getLogoutUrl($accessToken, $callback); $errorCode = 0; } else { //the first time we come to this page access token will be null $loginUrl = $helper->getLoginUrl($callback); $errorCode = 1; $user = null; } } catch (FacebookSDKException $e) { //the second time we come to this we might get this if something is wrong with login $errorCode = " 3 " . $e->getMessage(); $user = null; } ?> php-sdk

php-sdk

Logout
Login using OAuth 2.0 handled by the PHP SDK: Login with Facebook

PHP Session

You

Your User Object (/me)

You are not Connected.