I’ve manage a martial arts school’s website, the schook also has a facebook group where friends and students can publish their news and photos.
I would like to fetch the group’s albums and display their pictures in the website of the school.
So I tried this short script:
<?php
require_once(__DIR__.'/lib/facebook.php');
$facebook = new Facebook(array(
'appId' => 'API_KEY',
'secret' => 'API_SECRET',
));
$group = $facebook->api('GROUP_ID');
echo $group
?>
Which is raising this error in the app’s log
Wed Aug 10 01:16:30 2011] [error] [client 127.0.0.1] PHP Fatal error:
Uncaught CurlException: 6: name lookup timed out\n thrown in
‘./lib/base_facebook.php on line 814
So I wonder if this is the way to do it or if I should try getting the albums from elsewhere…
I find the documentation in developers.facebook.com scarce or confusing.
This is how I get my albums, I think the group album must be similar.
create a Facebook application. If you don’t already have one usable for this project create it on http://developers.facebook.com/setup/. You will own App Name, App URL, App ID, and App Secret get access code, go to:
https://www.facebook.com/dialog/oauth?client_id=Your_App_ID&redirect_uri=Your_App_URL&scope=read_stream,publish_stream,offline_access
You must allow the application to gain access to your account. (allow access to pictures to)
After you click allow, your browser will be redirect to Your_App_URL with additional URL attribute, it will look something like:
Your_App_URL?code=long_facebook_code
get offline access token, go to
https://graph.facebook.com/oauth/access_token?client_id=Your_App_ID&redirect_uri=Your_App_URL&client_secret=Your_App_Secret&code=long_facebook_code
the page will display something like
Note: make sure there are no word “expire=” in the end of the token (the bold text)
copy your offline token (only the bold text) and use it, it permanent token and never change event if you change your application name.
then I use a script in PHP (PHP SDK 3.0.):
to see available albums:
to read the album: