Facebook Offline Access Key and login
Right. After some more searching and poking around the code. I figured it out.
I've tested it out for multiple users and over the course of a week and it works like a charm.
When you have gotten the offline_access permission, store the session key, and the user ID. (wherever you want. I store mine in my database).
The infinite session key will look something like this df4175330aaddb9d50fd8f84-30000799
with everything after the 'dash' being the users ID.
Then the next time you call the API add this line of code in.
$this->fb->set_user('Facebook User ID', 'Offline Access Session key', 0);
N.B. the zero is the amount of time before it will expire. 0 = never.
My code in my library is as follows
$this->fb = new Facebook($this->_api_key, $this->_secret_key);
//Query Database to see if user had enabled offline access.
//If So extract the userid and session key
$this->fb->set_user($fbuserid, $fbsess, 0);
In my testing this has worked perfectly.
Now my users can log into my site and have facebook automatically, once they give the offline_access permission. Its currently been working for a week without problems.
I think thats everything. But if I left anything out let me know.
Facebook App: Where do i put offline_access request?
It's used with the API, as follows
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET,
'cookie' => false,
));
$facebook_login_url = $facebook->getLoginUrl(array(
'next' => '',
'cancel_url' => '',
'req_perms' => 'email,publish_stream,status_update'
));
Where $facebook_login_url
is the URL tha the user needs to follow to grant you access.
Does that help?
Related Topics
Resultset.Getstring(1) Throws Java.Sql.Sqlexception: Invalid Operation at Current Cursor Position
How to Stop a Scheduled Task That Was Started Using @Scheduled Annotation
How to Pass a Variable from One Thread Group to Another in Jmeter
Iterating Through a List in Reverse Order in Java
Java Int to String - Integer.Tostring(I) VS New Integer(I).Tostring()
Jackson Overcoming Underscores in Favor of Camel-Case
Calling Jmx Mbean Method from a Shell Script
How to Manually Set an Authenticated User in Spring Security/Springmvc
What Does This Thread Join Code Mean
How to Return JSON Data from Spring Controller Using @Responsebody
What Is the "Default" Implementation of Method Defined in an Interface
Sessions in Struts2 Application
What Does Maven Do, in Theory and in Practice? When Is It Worth to Use It
Is It Better Practice to Use String.Format Over String Concatenation in Java