The Graph API gives you access to public information. If you need more you have to have an access token. There are a couple of ways of gaining one, but first you need to create an application and get an App ID & App Secret.
- Create application here: http://www.facebook.com/developers/
- Click Setup Application in the upper right and follow the steps
- Create a link to the auth page:
- client_id should be set to your application ID. You can find it on this page.
- redirect_uri is the URL you want Facebook to redirect to with the access token in the URL in this format: http://example.com/facebook-app.php#access_token=452452ACCESS-TOKEN-HERE
- When the user clicks the link they will be brought to a Facebook Allow/Deny app page. If you need additional permissions such as access to feeds you’ll have to configure scope (&scope=read_stream,read_friendlist). Read here for more information.
- After the user allows the app they will be forwarded to the redirect_uri and the access token will be in the URL in the format mentioned above.
This code can be used to pull the access token out of the URL:
var url = location.href; var access_token = url.split('=').split('&'); /* Assumes default format without any parameters/variables added to the url by the user */
The access token can be accessed via the “access_token” variable