07-26-2023, 10:44 PM
With Symfony, it doesn't work because the way session are managed.
To resolve the problem you can create a new handler wich work with symfony's session.
FacebookDataHandlerSymfony.php :
<?php
use Facebook\PersistentData\PersistentDataInterface;
use Symfony\Component\HttpFoundation\Session\Session;
class FacebookDataHandlerSymfony implements PersistentDataInterface
{
private $session;
public function __construct()
{
$this->session = new Session();
}
public function get($key)
{
return $this->session->get('FBRLH_' . $key);
}
public function set($key, $value)
{
$this->session->set('FBRLH_' . $key, $value);
}
}
And when you create the FB Object, you have just to specifie the new class :
$this->fb = new Facebook([
'app_id' => '1234',
'app_secret' => '1324',
'default_graph_version' => 'v2.8',
'persistent_data_handler' => new FacebookDataHandlerSymfony()
]);
To resolve the problem you can create a new handler wich work with symfony's session.
FacebookDataHandlerSymfony.php :
<?php
use Facebook\PersistentData\PersistentDataInterface;
use Symfony\Component\HttpFoundation\Session\Session;
class FacebookDataHandlerSymfony implements PersistentDataInterface
{
private $session;
public function __construct()
{
$this->session = new Session();
}
public function get($key)
{
return $this->session->get('FBRLH_' . $key);
}
public function set($key, $value)
{
$this->session->set('FBRLH_' . $key, $value);
}
}
And when you create the FB Object, you have just to specifie the new class :
$this->fb = new Facebook([
'app_id' => '1234',
'app_secret' => '1324',
'default_graph_version' => 'v2.8',
'persistent_data_handler' => new FacebookDataHandlerSymfony()
]);