Displaying your facebook status on your website

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:

https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=123456789012345&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

you will see your 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.

[code]<!–?php $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 ‘
<strong>’ .$linkOpen .$status->name .$linkClose .'</strong>’;
echo ‘
‘;
echo ‘<span class="mini date f_f">’ .date("H:ia l dS F Y", strtotime($status->created_time)) .'</span>’;
echo ‘
‘;
echo $status->description .’
‘;
echo $linkOpen .$status->link .$linkClose;
echo ‘

‘;
}
}
?>[/code]

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




No Comments


You can leave the first : )



Leave a Reply

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