Skip to content

Instantly share code, notes, and snippets.

@kikegarcia
Created July 8, 2013 08:24
Show Gist options
  • Save kikegarcia/5947123 to your computer and use it in GitHub Desktop.
Save kikegarcia/5947123 to your computer and use it in GitHub Desktop.
Facebook Wall to PHP class with FB API
<?php
/**
* Profile controller
* Delegates control to profile controllers to seperate the distinct profile features
*/
class Facebookcontroller {
/**
* Constructor
* @param Object $registry the registry
* @param bool $directCall - are we directly accessing this controller?
*/
public function __construct( $registry, $directCall=true, $pagid )
{
$this->registry = $registry;
$urlBits = $this->registry->getObject('url')->getURLBits();
if( isset( $urlBits[1] ) )
{
switch( isset( $urlBits[1] ) ? $urlBits[1] : '' )
{
default:
$this->facebookhome();
break;
}
} else {
$this->facebookhome();
}
}
/**
* Delegate control to the static content profile controller
* @param int $user the user whose profile we are viewing
* @return void
*/
private function facebookhome()
{
$yourAppId = "";
$yourSecret = "";
include('controllers/facebook/src/facebook.php');
$fb_config = array(
'appId' => $yourAppId,
'secret' => $yourSecret,
);
$facebook = new Facebook($fb_config);
$feed = $facebook->api("/randomfanpage/feed?limit=2");
$mensaje1 = $feed['data'][0]['message'];
$mensaje2 = $feed['data'][1]['message'];
// change as you needed
// date_default_timezone_set('Asia/Manila');
$this->registry->getObject('template')->getPage()->addTag( 'mensaje1', $mensaje1 );
$this->registry->getObject('template')->getPage()->addTag( 'mensaje2', $mensaje2 );
$this->registry->getObject('template')->buildFromTemplates( 'facebook.tpl.php' );
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment