FriendsOfSymfony / FOSFacebookBundle

NOT MAINTAINED - see https://github.com/hwi/HWIOAuthBundle
322 stars 140 forks source link

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

Open warguns opened 11 years ago

warguns commented 11 years ago

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?

lionelbzv commented 11 years ago

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?