First use this url to ask user to add your facebook app(if user not login, facebook will redirect to login page and then go to this url)
https://graph.facebook.com/oauth/authorize?redirect_uri=< http://YOUR_FaceBookCallback_SERVLET>&client_id=<YOUR_app_key>
Then you can use this url to ask user grant the extend permission(allow offline access)
http://www.facebook.com/authorize.php?api_key=<YOUR_app_key>&v=1.0&ext_perm=offline_access&next=< http://YOUR_FaceBookCallback_SERVLET>=true&return_session=true
Then you will have an auth_token in the url, use Get to take it out and use it to generate the infinite session key. For php version, it looks like this:
1. $auth_token=$_GET['auth_token'];
2. $infinite_key_array = $facebook->api_client->auth_getSession($auth_token);
3. print_r($infinite_key_array); if the key is infinite, the expire will be 0
The result will be: Array ( [session_key] => c03eed6d6f07f335d4a36cd2-598500288 [uid] => 598500288 [expires] => 0 )
c03eed6d6f07f335d4a36cd2 is the key , while 598500288 is the user id
Thus you can store the infinite key for future use
Optional reading:
1.This mention Facebook is going to stop granting infinite sessions to Web-based applications automatically,
Desktop applications will continue to be granted a 24 hour session key, and mobile clients will continue to receive infinite sessions :
http://wiki.developers.facebook.com/index.php/New_Design_Platform_Changes#Changes_to_Session_Keys
https://graph.facebook.com/oauth/authorize?redirect_uri=< http://YOUR_FaceBookCallback_SERVLET>&client_id=<YOUR_app_key>
Then you can use this url to ask user grant the extend permission(allow offline access)
http://www.facebook.com/authorize.php?api_key=<YOUR_app_key>&v=1.0&ext_perm=offline_access&next=< http://YOUR_FaceBookCallback_SERVLET>=true&return_session=true
Then you will have an auth_token in the url, use Get to take it out and use it to generate the infinite session key. For php version, it looks like this:
1. $auth_token=$_GET['auth_token'];
2. $infinite_key_array = $facebook->api_client->auth_getSession($auth_token);
3. print_r($infinite_key_array); if the key is infinite, the expire will be 0
The result will be: Array ( [session_key] => c03eed6d6f07f335d4a36cd2-598500288 [uid] => 598500288 [expires] => 0 )
c03eed6d6f07f335d4a36cd2 is the key , while 598500288 is the user id
Thus you can store the infinite key for future use
Optional reading:
1.This mention Facebook is going to stop granting infinite sessions to Web-based applications automatically,
Desktop applications will continue to be granted a 24 hour session key, and mobile clients will continue to receive infinite sessions :
http://wiki.developers.facebook.com/index.php/New_Design_Platform_Changes#Changes_to_Session_Keys