How to login with OFFLINE_ACCESS using the new Facebook PHP SDK 3.0.0?

With the Facebook PHP SDK v3 ( see on github ), it is pretty simple. To log someone with the offline_access permission, you ask it when your generate the login URL. Here is how you do that Get the offline access token First you check if the user is logged in or not : require "facebook.

Php"; $facebook = new Facebook(array( 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { // The access token we have is not valid $user = null; } } If he is not, you generate the "Login with Facebook" URL asking for the offline_access permission : if (!$user) { $args'scope' = 'offline_access'; $loginUrl = $facebook->getLoginUrl($args); } And then display the link in your template :? Php if (!$user):? > ">Login with Facebook getAccessToken() Use the offline access token To use the offline access token when the user is not logged in : require "facebook.

Php"; $facebook = new Facebook(array( 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); $facebook->setAccessToken("...") And now you can make API calls for this user : $user_profile = $facebook->api('/me') Hope that helps!

With the Facebook PHP SDK v3 (see on github), it is pretty simple. To log someone with the offline_access permission, you ask it when your generate the login URL. Here is how you do that.

Get the offline access token First you check if the user is logged in or not : require "facebook. Php"; $facebook = new Facebook(array( 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { // The access token we have is not valid $user = null; } } If he is not, you generate the "Login with Facebook" URL asking for the offline_access permission : if (!$user) { $args'scope' = 'offline_access'; $loginUrl = $facebook->getLoginUrl($args); } And then display the link in your template : ">Login with Facebook Then you can retrieve the offline access token and store it. To get it, call : $facebook->getAccessToken() Use the offline access token To use the offline access token when the user is not logged in : require "facebook.

Php"; $facebook = new Facebook(array( 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); $facebook->setAccessToken("..."); And now you can make API calls for this user : $user_profile = $facebook->api('/me'); Hope that helps!

– Brenden Jun 17 at 22:26 There is no documentation for the PHP SDK in the Facebook developer documentation. You can read the code, read the example provided with the SDK and find some other examples on internet.Do you need something else specific? – Quentin Jun 17 at 23:20.

With PHP SDK 2.0 (I guess), I just use it like $data = $facebook->api( '/me', 'GET', array( 'access_token' => $userdata'fb_access_token' ) ); This should work with the newer one to as it seems to be more of a clean approach than rather setting up sessions by ourself. Can you try?

In the new SDK this function doesn't exist anymore. But this function is protected and I don't know what 'code' is? Do I need this to log the user in or not?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions