Offline with HybridAuth

I already allowed the user in my Facebook application to use HybridAuth and saved his access_token in my database.

A few days later, when the user is not connected to the network, I want to get his new friends on Facebook, also using HybridAuth.

Can I recreate this user from his access_token to receive his friends, send notifications, etc.?

Thanks!

+6
source share
2 answers

I finally found a hack that works, I will leave it here for the next guy who is looking for it. If you verify that you have a valid token for your user and application, HybridAuth should not attempt to redirect or return any errors.

(I use Codeigniter, but translating it to a "clean" HybridAuth should be simple:

$token = "GET A TOKEN IN Facebook API EXPLORER"; $this->load->library('HybridAuthLib'); $this->hybridauthlib->storage()->set( "hauth_session.facebook.is_logged_in", 1 ); $this->hybridauthlib->storage()->set( "hauth_session.facebook.token.access_token", $token ); $service = $this->hybridauthlib->authenticate('Facebook'); if ($service->isUserConnected()){ $user_profile = $service->getUserProfile(); $contacts = $service->getUserContacts(); $access_token = $service->getAccessToken(); var_dump($user_profile); var_dump($contacts); var_dump($access_token); }else{ echo "something went wrong"; } 
+7
source

Although the above may work, I believe the recommended approach would be to use Persistent Sessions, as described here: http://hybridauth.sourceforge.net/userguide/HybridAuth_Sessions.html

+1
source