it’s done with this.
$_SESSION['fb_access_token'] = (string) $accessToken;
$fbApp = new Facebook\FacebookApp('1014758295283866', 'b1a98e587c8bef98dfb273db67214afb');
$request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', '/me', ['fields' => 'id,name,email']);
try {
$response = $fb->getClient()->sendRequest($request);
} 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;
}
$graphNode = $response->getGraphNode();
include "config.php";
$query = "INSERT INTO users VALUES ('', '".$graphNode['name']."', '".$graphNode['email']."')";
$result = mysql_query($query);
if ($result) {
// User is logged in with a long-lived access token.
// You can redirect them to a members-only page.
header('location:index.php');
}
else{
echo "Problem In Login";
}
solved login with facebook with database