2017 © Pedro Peláez
 

library facebook

Facebook OAuth v4 for Laravel Framework

image

pingpong/facebook

Facebook OAuth v4 for Laravel Framework

  • Thursday, April 30, 2015
  • by gravitano
  • Repository
  • 4 Watchers
  • 9 Stars
  • 29,543 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Facebook PHP SDK v4 for Laravel

Build Status, (*1)

Server Requirement

This package is require PHP 5.4 or higher., (*2)

Installation

For Laravel 4 please use version 1.*., (*3)

Open your composer.json file, and add the new required package., (*4)

   "pingpong/facebook": "~2.0"

Next, open a terminal and run., (*5)

composer update

Next, Add new service provider in app/config/app.php., (*6)

  'Pingpong\Facebook\FacebookServiceProvider',

Next, Add new aliases in app/config/app.php., (*7)

   'Facebook' => 'Pingpong\Facebook\Facades\Facebook',

Next, publish the configuration., (*8)

php artisan vendor:publish --provider="Pingpong\Facebook\FacebookServiceProvider"

Done., (*9)

Usage

First, you must set the app_id and the app_secret in the configuration file. You can also set the default scope and the redirect url., (*10)

return array(
    'app_id'        =>  '',
    'app_secret'    =>  '',
    'redirect_url'  =>  url('facebook/callback'),
    'scope'         =>  array(
        'publish_actions',
        'email'
    )
);

Get facebook login url., (*11)

Facebook::getLoginUrl();

You can also update the scope., (*12)

$scope = array('email');

Facebook::getLoginUrl($scope);

Authenticate the user and get the permissions. This will automatically redirect the user to the facebook login url., (*13)

Facebook::authenticate();

If you want to update/override the scope, you can add the scope in the first parameter., (*14)

$scope = array('email');

Facebook::authenticate($scope);

You can also set the version of Facebook API want to use., (*15)

$version = 'the-version';
$scope = array('email');

Facebook::authenticate($scope, $version);

By default when you login to to facebook using oauth, it will show you a login page in website version. If you want to using popup version, call displayAsPopup method., (*16)

Facebook::displayAsPopup();

return Facebook::authenticate($scope, $version);

Get user profile for the current logged in user., (*17)

Facebook::getProfile();

Get call back from redirect. Will return a value of true if the authentication is successful and otherwise., (*18)

Facebook::getCallback();

Logout the current active user., (*19)

Facebook::destroy();
// or
Facebook::logout();

Call the Facebook API., (*20)

Facebook::api($method, $path, $parameters, $version);

Facebook::api('GET', '/me');

Facebook::api('POST', '/me/feed', $parameters);

Facebook::api('PUT', '/path', $parameters);

Facebook::api('PATCH', '/path', $parameters);

Facebook::api('DELETE', '/path/to', $parameters);

Helper method for call Facebook API., (*21)

GET Request, (*22)

Facebook::get('/path', $parameters);

POST Request, (*23)

Facebook::post('/path', $parameters);

PUT Request, (*24)

Facebook::put('/path', $parameters);

PATCH Request, (*25)

Facebook::patch('/me', $parameters);

DELETE Request, (*26)

Facebook::delete('/me', $parameters);

Example

Authentication and authorization, (*27)

Route::group(['prefix' => 'facebook'], function ()
{
    Route::get('connect', function ()
    {
        return Facebook::authenticate();
    });

    Route::get('callback', function ()
    {
        $callback = Facebook::getCallback();

        if($callback)
        {
            $profile = Facebook::getProfile();

            dd($profile);
        }

        dd($callback);
    });
});

License

This package is open-sourced software licensed under The BSD 3-Clause License, (*28)

The Versions

30/04 2015

dev-master

9999999-dev

Facebook OAuth v4 for Laravel Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4

30/04 2015

dev-develop

dev-develop

Facebook OAuth v4 for Laravel Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4

30/04 2015

2.0.1

2.0.1.0

Facebook OAuth v4 for Laravel Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4

28/04 2015

2.0.0

2.0.0.0

Facebook OAuth v4 for Laravel Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4

07/10 2014

1.0.1

1.0.1.0

Facebook OAuth v4 for Laravel Framework

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4

17/08 2014

1.0.0

1.0.0.0

Laravel 4 - Simple OAuth Facebook v4

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api oauth facebook guzzle facebook-v4