FOSFacebookBundle icon indicating copy to clipboard operation
FOSFacebookBundle copied to clipboard

can't use facebook php api calls when user are logged in on the controller (access_token lost)

Open warguns opened this issue 12 years ago • 1 comments

When a user logs with my FosFacebookBundle, generates three session variables:

_fos_facebook_fb_numbers_access_token _fos_facebook_fb_numbers_code _fos_facebook_fb_numbers_user_id

I use the service getter to retrieve the facebook api object on the redirected controller after login

$facebook = $this->get("fos_facebook.api");

but when I do an API call with the object:

$fbData = $facebook->api("/me/accounts");

Loses that session variables and gives me the access_token error

of course, the facebook user are logged with the roles and the users session

I tried to comment the content of the method clearAllPersistentData in FacebookSessionPersistence and after one page reload (maybe the API object needs to reasign the sessions variables) gets the access_token and gives me the facebook response array with data.

What can I do? I have to get this variables from the session and use directly the facebook php sdk or I'm doing something wrong with the code?

warguns avatar Jan 28 '13 10:01 warguns

up

This code gives me access to the API

$fbuser = $this->get('my.facebook.user');
$apiservice = $this->get('fos_facebook.api');
$userdata = $apiservice->api('/me/'.$apiMethodName);

Perhaps it's only a session lifetime problem between facebook login & application?

lionelbzv avatar Aug 15 '13 10:08 lionelbzv