GithubHelp home page GithubHelp logo

steffenmllr / li3_facebook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mgcrea/li3_facebook

1.0 3.0 1.0 986 KB

Facebook plugin for lithium

Home Page: http://mgcrea.github.com/li3_facebook/

PHP 100.00%

li3_facebook's Introduction

 ___           __                ___                       __                      __         
/\_ \    __  /'__`\            /'___\                     /\ \                    /\ \        
\//\ \  /\_\/\_\L\ \          /\ \__/   __      ___     __\ \ \____    ___     ___\ \ \/'\    
  \ \ \ \/\ \/_/_\_<_  _______\ \ ,__\/'__`\   /'___\ /'__`\ \ '__`\  / __`\  / __`\ \ , <    
   \_\ \_\ \ \/\ \L\ \/\______\\ \ \_/\ \L\.\_/\ \__//\  __/\ \ \L\ \/\ \L\ \/\ \L\ \ \ \\`\  
   /\____\\ \_\ \____/\/______/ \ \_\\ \__/.\_\ \____\ \____\\ \_,__/\ \____/\ \____/\ \_\ \_\
   \/____/ \/_/\/___/            \/_/ \/__/\/_/\/____/\/____/ \/___/  \/___/  \/___/  \/_/\/_/

Facebook API library for the lithium framework

quick setup

In your bootstrap/session.php

use lithium\storage\Session;

Session::config(array(
	'default' => array('adapter' => 'Php')
));

use lithium\security\Auth;

Auth::config(array(
	'facebook' => array(
		'adapter' => 'Facebook',
		'app_id'      => 'FB_APP_ID_HERE',
		'api_key'     => 'FB_API_KEY_HERE',
		'app_secret'  => 'FB_APP_SECRET_HERE'
	)
));

use lithium\action\Dispatcher;
use lithium\action\Response;

Dispatcher::applyFilter('_callable', function($self, $params, $chain) {
	$controller = $chain->next($self, $params, $chain);
	
	if (Auth::check('facebook', $params['request'], array('checkSession' => false))) {
		return $controller;
	}
	if (isset($ctrl->publicActions) && in_array($params['request']->action, $ctrl->publicActions)) {
		return $controller;
	}
	return function() {
		return new Response(array('location' => '/login'));
	};
});

In one of your controller

use facebook\models\Friends as FacebookFriends;

class UsersController extends \lithium\action\Controller {
	
	public function index() {
		
		// Retreive user info from Facebook auth adapter
		$fbAuth = Auth::config('facebook');
		$fbUser = $fbAuth['object']->get('me');
		
		// Check for a match in db
		$user = Users::find('first', array('conditions' => array('email' => $fbUser['email'])));
		
		// Retrieve all friends
		$allFriends = FacebookFriends::all(array('limit' => 5, 'offset' => 0));
		
	}

}

For Docs, License, Tests, and pre-packed downloads, see:

http://mgcrea.github.com/li3-facebook/

To suggest a feature, report a bug, or general discussion:

http://mgcrea.github.com/li3-facebook/issues/

All contributors are listed here:

http://mgcrea.github.com/li3-facebook/contributors

li3_facebook's People

Contributors

mgcrea avatar steffenmllr avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

d1rk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.