Display facebook status & wall posts on your website

first you need 3 things: your user id, your app id and app secret, you can do this from within the app edit screen on facebook.

once you have these keys, we need to generate an access_token. we can get this by visiting an url using our app id and secret:


you will see you access_token printed out in your browser.

so, the following snippet of code, using your user id and access_token, will grab the latest public posts from your wall.

$access_token = '123456789012345|-xXxXxXxXxXxXxXxXxXxXxXxXxX'; 
$user_id = '00000000000';
$url = 'https://graph.facebook.com/'.$user_id.'/feed?access_token=' .$access_token;
$json = file_get_contents($url);
$data = json_decode($json);
if ( !empty($data) )
	foreach ($data=>data as $status)
		if ( !empty($status->link) )
			$linkOpen = '<a class="button" href="' .$status->link .'">';
			$linkClose = '</a>';
		echo '<p><strong>' .$linkOpen .$status->name .$linkClose .'</strong>';
		echo '<p>';
			echo '<span class="mini date f_f">' .date("H:ia l dS F Y", strtotime($status->created_time)) .'</span>';
			echo '<br />';
			echo $status->description .'<br />';
			echo $linkOpen .$status->link .$linkClose;
		echo '</p>';

excuse the html and class names etc, i’m sure you’ll want to markup your own pages :)

Leave a Reply

Your email address will not be published. Required fields are marked *