public function SimpleFbConnectFbManager::getFbSession in Simple FB Connect 8.2
Returns FacebookSession for the current user.
Other modules can use this function to get FacebookSession object in order to make their own requests to Facebook API.
This function validates the session by checking that user's access token (stored in Drupal session) is still valid and from our FB app.
Return value
\Facebook\FacebookSession|false FacebookSession if the token was valid False otherwise
File
- src/
SimpleFbConnectFbManager.php, line 186 - Contains \Drupal\simple_fb_connect\SimpleFbConnectFbManager.
Class
- SimpleFbConnectFbManager
- Contains all Simple FB Connect logic that is related to Facebook interaction.
Namespace
Drupal\simple_fb_connectCode
public function getFbSession() {
try {
// Get user access token from Drupal session.
$user_token = $this->session
->get('simple_fb_connect_user_token');
$fb_session = new FacebookSession($user_token);
// Validate the session (token is not expired and token is from our app).
$fb_session
->validate();
return $fb_session;
} catch (\Exception $ex) {
$this->loggerFactory
->get('simple_fb_connect')
->error('FacebookSession validation failed. Exception: @message', array(
'@message' => $ex
->getMessage(),
));
}
return FALSE;
}