Facebook group posts on own webpage in PHP

A friend needed his FB groups posts embedded on his webpage so here are some snippets that I don’t forget 😀

  1. At https://developers.facebook.com create a new APP, after creating you get the required ID and SECRET.
  2. From https://github.com/facebook/facebook-php-sdk download the PHP SDK


require_once(WB_PATH."/include/facebook/src/facebook.php"); // Get from https://github.com/facebook/facebook-php-sdk

$APP_ID = 'APPID';
$APP_SECRET = 'APPSECRET';
$GROUP_ID = 'GROUPID';

$config = array(
'appId' => $APP_ID,
'secret' => $APP_SECRET,
'fileUpload' => false,
'allowSignedRequest' => false,
);

$facebook = new Facebook($config);
extract($facebook->api("/$GROUP_ID/feed?limit=10"));

$posts = '';
foreach ($data as $d) {
if (!empty($d['message'])) {
$posts .= '

  • '.date('d.m.Y H:i', strtotime($d['created_time'])).'

    '.$d['message'].'


  • ';
    }
    }

    During googling I found http://pastebin.com/LPnzUQSF, but I didn’t try.

    Advertisements

    Author: Michal Zuber

    Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s