PHPackages                             pingpong/facebook - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. pingpong/facebook

ActiveLibrary[HTTP &amp; Networking](/categories/http)

pingpong/facebook
=================

Facebook OAuth v4 for Laravel Framework

2.0.1(11y ago)929.7k7[1 issues](https://github.com/pingpong-labs/facebook/issues)BSD-3-ClausePHPPHP &gt;=5.4.0

Since Aug 17Pushed 8y ago3 watchersCompare

[ Source](https://github.com/pingpong-labs/facebook)[ Packagist](https://packagist.org/packages/pingpong/facebook)[ RSS](/packages/pingpong-facebook/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

Facebook PHP SDK v4 for Laravel
-------------------------------

[](#facebook-php-sdk-v4-for-laravel)

[![Build Status](https://camo.githubusercontent.com/35828532934e73eb5749c3126e70746d219ca9bbb295797ce0a7593452114e0d/68747470733a2f2f7472617669732d63692e6f72672f70696e67706f6e672d6c6162732f66616365626f6f6b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pingpong-labs/facebook)

### Server Requirement

[](#server-requirement)

This package is require PHP 5.4 or higher.

### Installation

[](#installation)

> For Laravel 4 please use version `1.*`.

Open your composer.json file, and add the new required package.

```
   "pingpong/facebook": "~2.0"

```

Next, open a terminal and run.

```
composer update

```

Next, Add new service provider in `app/config/app.php`.

```
  'Pingpong\Facebook\FacebookServiceProvider',
```

Next, Add new aliases in `app/config/app.php`.

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

Next, publish the configuration.

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

```

Done.

### Usage

[](#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.

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

Get facebook login url.

```
Facebook::getLoginUrl();
```

You can also update the scope.

```
$scope = array('email');

Facebook::getLoginUrl($scope);
```

Authenticate the user and get the permissions. This will automatically redirect the user to the facebook login url.

```
Facebook::authenticate();
```

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

```
$scope = array('email');

Facebook::authenticate($scope);
```

You can also set the version of Facebook API want to use.

```
$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.

```
Facebook::displayAsPopup();

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

Get user profile for the current logged in user.

```
Facebook::getProfile();
```

Get call back from redirect. Will return a value of true if the authentication is successful and otherwise.

```
Facebook::getCallback();
```

Logout the current active user.

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

Call the Facebook API.

```
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.

GET Request

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

POST Request

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

PUT Request

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

PATCH Request

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

DELETE Request

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

### Example

[](#example)

**Authentication and authorization**

```
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

[](#license)

This package is open-sourced software licensed under [The BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 91.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Total

4

Last Release

4036d ago

Major Versions

1.0.1 → 2.0.02015-04-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/5221291be74d1e0ddef6931aa833f02a106df5b972431926321bf4f12d16b62b?d=identicon)[gravitano](/maintainers/gravitano)

---

Top Contributors

[![gravitano](https://avatars.githubusercontent.com/u/5087538?v=4)](https://github.com/gravitano "gravitano (21 commits)")[![d4rkd0s](https://avatars.githubusercontent.com/u/2348814?v=4)](https://github.com/d4rkd0s "d4rkd0s (1 commits)")[![diego1araujo](https://avatars.githubusercontent.com/u/4531801?v=4)](https://github.com/diego1araujo "diego1araujo (1 commits)")

---

Tags

apilaravelfacebookGuzzleoauthfacebook-v4

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pingpong-facebook/health.svg)

```
[![Health](https://phpackages.com/badges/pingpong-facebook/health.svg)](https://phpackages.com/packages/pingpong-facebook)
```

###  Alternatives

[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[hamburgscleanest/guzzle-advanced-throttle

A Guzzle middleware that can throttle requests according to (multiple) defined rules. It is also possible to define a caching strategy, e.g. get response from cache when rate limit is exceeded or always get cached value to spare your rate limits.

13033.4k1](/packages/hamburgscleanest-guzzle-advanced-throttle)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
