---
title: "FaceBook Setup Issue"
author: "eonbell"
date: "2011-02-25T13:37:30Z"
tags: []
categories: ["编程语言"]
slug: "facebook-setup-issue"
draft: false
lastmod: "2011-02-25T13:37:30Z"
id: 929731
url: "https://eonbell.iteye.com/blog/929731"
---

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>&amp;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;
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 (  => c03eed6d6f07f335d4a36cd2-598500288  => 598500288  => 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