Facebook-PHP-SDK-for-Zend-Framework is a project mainly written in PHP, it's free.
A couple of classes that you can include in your library to use within Zend Framework projects.
The purpose of the Zend Framework Facebook Library is to provide a simple (and standarized) way in which you can use the Facebook PHP SDK classes within the recommended ZF project folder hierarchy.
It's based on the Official Facebook PHP SDK. It has been modified so that all classes follow ZF naming guidelines and a Resource has been created so that you can easily set your params from application.ini
Simply, copy the Facebook folder to your ZF library folder and add the following lines to your application/configs/application.ini file replacing APP_ID and APP_SECRET with your own.
autoloadernamespaces[] = "Facebook_" pluginPaths.Facebook_Resource = APPLICATION_PATH "/../library/Facebook/Resource" resources.facebook.appid = "APP_ID" resources.facebook.secret = "APP_SECRET"
From any Controller or Model, you can get the Facebook_Facebook object by reading the registry key 'Facebook', after doing so you can call any of the available methods from Facebook Docs.
$facebook = Zend_Registry::get('Facebook'); $user = $facebook->getUser();
if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); } catch (Facebook_Api_Exception $e) { $user = null; } }
// Login or logout url will be needed depending on current user state. if ($user) { $logoutUrl = $facebook->getLogoutUrl(); $this->view->link = $logoutUrl; $this->view->user = $user_profile; } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'email,publish_stream')); $this->view->link = $loginUrl; }