scence / lbook
Facebook authentication package for Laravel 4. It Uses Facebook PHP SDK v4
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: *
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2019-03-08 20:54:47 UTC
README
Server Requirement
PHP 5.4 or higher also Facebook SDK v4
Installation
Open your composer.json file, and add the required package.
"scence/lbook": "dev-master"
After that run this terminal command
composer update
Next add new service provider in app/config/app.php
'Scence\Lbook\LbookServiceProvider',
Now publish the configuration file
php artisan config:publish scence/lbook
Now go to app/config/packages/scence/lbook/config.php
and fill in you'r appId and secret also redirectUrl and logoutUrl
Thats it.
Usage
LoginUrl
echo Lbook::getLoginUrl($before = null, $label = 'Login', $after = null, $attributes = array());
Ex:
echo Lbook::getLoginUrl('<b>', 'Sing In', '</b>, array('class' => 'your-btn-class', 'id' => 'your-button-id-class'));
LogoutUrl
echo Lbook::getLoginUrl($before = null, $label = 'Login', $after = null, $attributes = array());
Ex:
echo Lbook::getLoginUrl('<i>', 'Log Out', '</i>, array('class' => 'your-btn-class', 'id' => 'your-button-id-class'));
UserProfile
Ex:
echo Lbook::getUserProfile()->getName();
Will return the logged user first_name & last_name. More info at Facebook SDK Documentation
Login Status
var_dump(Lbook::getLoginStatus());
Returns Boolean True/False
Api Calls
Lbook::api($method, $path, $parameters = null, $session = null, $version = null, $etag = null);
Post Ex:
$post_to_wall = Lbook::api('POST', '/me/feed', array('message' => 'just testing')); var_dump($post_to_wall);
If you want to post as page fill in the 4th argument "$session" (page access_token)
Minimal Usage
Route::get('/', function() { if (Lbook::getLoginStatus() === False) { echo Lbook::getLoginUrl(); } else { echo Lbook::getLogoutUrl(); } }); Route::get('profile', function(){ echo Lbook::getUserProfile()->getName(); }); Route::get('logout', function() { Session::flush(); return Redirect::to('/'); });