PHPackages                             contributte/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. contributte/facebook

Abandoned → [league/oauth2-facebook](/?search=league%2Foauth2-facebook)ArchivedLibrary

contributte/facebook
====================

Easy-to-use Facebook login wrapper for \[`Nette Framework`\](https://github.com/nette/).

v0.4.0(3y ago)11651.9k↑68.8%10MITPHPPHP &gt;=7.2

Since Oct 10Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/contributte/facebook)[ Packagist](https://packagist.org/packages/contributte/facebook)[ Docs](https://github.com/contributte/facebook)[ Fund](https://contributte.org/partners.html)[ GitHub Sponsors](https://github.com/f3l1x)[ RSS](/packages/contributte-facebook/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (9)Versions (6)Used By (0)

[![](https://camo.githubusercontent.com/04e4907ef6494ee9ab51c2517bcb1fd6ef8a2f1c2ddc43dd95dd50de8e84e5b4/68747470733a2f2f686561746261646765722e76657263656c2e6170702f6769746875622f726561646d652f636f6e74726962757474652f66616365626f6f6b2f3f646570726563617465643d31)](https://camo.githubusercontent.com/04e4907ef6494ee9ab51c2517bcb1fd6ef8a2f1c2ddc43dd95dd50de8e84e5b4/68747470733a2f2f686561746261646765722e76657263656c2e6170702f6769746875622f726561646d652f636f6e74726962757474652f66616365626f6f6b2f3f646570726563617465643d31)

 [![](https://camo.githubusercontent.com/a8b1cd856d7d396fdebbe46947cc3507490acc267a02361e5e53bb7b820c95c3/68747470733a2f2f62616467656e2e6e65742f62616467652f737570706f72742f6769747465722f6379616e)](https://bit.ly/ctteg) [![](https://camo.githubusercontent.com/86d6416fc04f8bcc3daa7bf881526b9953b9726b1164d05c157c8713e3a73418/68747470733a2f2f62616467656e2e6e65742f62616467652f737570706f72742f666f72756d2f79656c6c6f77)](https://bit.ly/cttfo) [![](https://camo.githubusercontent.com/5d170ab94e6d594609561e16fe0f9e4293968fbd4dfcfafc5e11efc1415ef09c/68747470733a2f2f62616467656e2e6e65742f62616467652f73706f6e736f722f646f6e6174696f6e732f463936383534)](https://contributte.org/partners.html)

 Website 🚀 [contributte.org](https://contributte.org) | Contact 👨🏻‍💻 [f3l1x.io](https://f3l1x.io) | Twitter 🐦 [@contributte](https://twitter.com/contributte)

Disclaimer
----------

[](#disclaimer)

⚠️This project is no longer being maintained.Composer[`contributte/facebook`](https://packagist.org/packages/contributte/facebook)Version[![](https://camo.githubusercontent.com/b9830cf6e69d21b8cb435e48221b5cf450c752fe48cf30c4799b9f30fe04a141/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f636f6e74726962757474652f66616365626f6f6b)](https://camo.githubusercontent.com/b9830cf6e69d21b8cb435e48221b5cf450c752fe48cf30c4799b9f30fe04a141/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f636f6e74726962757474652f66616365626f6f6b)PHP[![](https://camo.githubusercontent.com/f7de6886c6452f0a1f39e7dad72870790da7c8fb816890e23451e6b3ebf46175/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f636f6e74726962757474652f66616365626f6f6b)](https://camo.githubusercontent.com/f7de6886c6452f0a1f39e7dad72870790da7c8fb816890e23451e6b3ebf46175/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f636f6e74726962757474652f66616365626f6f6b)License[![](https://camo.githubusercontent.com/944ab2833ced8eda193bb45084e00fb449219ec72d4765de81b815cb7d2ecace/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f636f6e74726962757474652f66616365626f6f6b)](https://camo.githubusercontent.com/944ab2833ced8eda193bb45084e00fb449219ec72d4765de81b815cb7d2ecace/68747470733a2f2f62616467656e2e6e65742f6769746875622f6c6963656e73652f636f6e74726962757474652f66616365626f6f6b)About
-----

[](#about)

Easy-to-use Facebook login wrapper for [`Nette Framework`](https://github.com/nette/).

Installation
------------

[](#installation)

```
composer require contributte/facebook
```

Setup
-----

[](#setup)

```
extensions:
	facebook: Contributte\Facebook\DI\Nette\FacebookExtension
```

If you are using PHP 8.0+, you need to use forked version of `facebook/graph-sdk`. You can rely on our fork [holyfork/facebook-graph-sdk](https://github.com/holyfork/facebook-graph-sdk), it's tested and working.

```
{
  "repositories": [
    { "type": "git", "url": "https://github.com/holyfork/facebook-graph-sdk" }
  ]
}
```

Configuration
-------------

[](#configuration)

You need to create a FacebookApp and supply these parameters:

- **appId**
- **appSecret**
- **defaultGraphVersion** (optional)
- **persistentDataHandler** (optional) default value: **session**
- **httpClientHandler** (optional)

```
facebook:
	appId: %yourAppId%
	appSecret: %yourAppSecret%
```

Usage
-----

[](#usage)

Simple example how to use Facebook Login in Presenter

```
namespace App\Presenters;

use Contributte\Facebook\Exceptions\FacebookLoginException;
use Contributte\Facebook\FacebookLogin;
use Nette\Application\Responses\RedirectResponse;
use Nette\Application\UI\Presenter;
use Nette\Security\AuthenticationException;

final class SignPresenter extends Presenter
{

	/** @var FacebookLogin @inject */
	public $facebookLogin;

	public function actionFacebook()
	{
		// Redirect to FB and ask customer to grant access to his account
		$url = $this->facebookLogin->getLoginUrl($this->link('//facebookAuthorize'), ['email', 'public_profile']);
		$this->sendResponse(new RedirectResponse($url));
	}

	/**
	 * Log in user with accessToken obtained after redirected from FB
	 *
	 * @return void
	 */
	public function actionFacebookAuthorize()
	{
		// Fetch User data from FB and try to login
		try {
			$token = $this->facebookLogin->getAccessToken();

			$this->user->login('facebook', $this->facebookLogin->getMe($token->getValue(), ['first_name', 'last_name', 'email', 'gender']));
			$this->flashMessage('Login successful :-).', 'success');
		} catch (FacebookLoginException | AuthenticationException $e) {
			$this->flashMessage('Login failed. :-( Try again.', 'danger');
		}
	}

}
```

If you need to specify your own state param (more info [here](https://developers.facebook.com/docs/facebook-login/security/#stateparam) mind also checking Enable Strict Mode). `Facebook::getLoginUrl()` takes optional third parameter `$stateParam` which FB passes back unchanged.

JavaScript Login
----------------

[](#javascript-login)

You can also use FB login button, for example:

```

Login

```

And use `onlogin` event to call backend code which takes care of registration/login process:

```
/**
 * Log in user with accessToken from cookie/session after javascript authorization
 */
public function actionFacebookCookie()
{
	// Fetch User data from FB and try to login
	try {
		$token = $this->facebookLogin->getAccessTokenFromCookie();

		$this->user->login('facebook', $this->facebookLogin->getMe($token, ['first_name', 'last_name', 'email', 'gender']));
		$this->flashMessage('Login successful :-).', 'success');
	} catch (FacebookLoginException | AuthenticationException $e) {
		$this->flashMessage('Login failed. :-( Try again.', 'danger');
	}
}
```

Versions
--------

[](#versions)

StateVersionBranchNettePHPdev`^0.4``master`3.0+`>=7.2`stable`^0.3``master`3.0+`^7.2`stable`^0.2``master`2.4`>=7.1`Development
-----------

[](#development)

This package was maintained by these authors.

[ ![](https://avatars2.githubusercontent.com/u/538058?v=3&s=80)](https://github.com/f3l1x)---

Consider to [support](https://contributte.org/partners.html) **contributte** development team. Also thank you for using this package.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance54

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~580 days

Total

4

Last Release

1345d ago

PHP version history (3 changes)v0.1PHP &gt;= 7.1

v0.3.0PHP ^7.2

v0.4.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/538058?v=4)[Milan Šulc](/maintainers/f3l1x)[@f3l1x](https://github.com/f3l1x)

---

Top Contributors

[![f3l1x](https://avatars.githubusercontent.com/u/538058?v=4)](https://github.com/f3l1x "f3l1x (15 commits)")[![mabar](https://avatars.githubusercontent.com/u/20974277?v=4)](https://github.com/mabar "mabar (4 commits)")[![vody105](https://avatars.githubusercontent.com/u/22433893?v=4)](https://github.com/vody105 "vody105 (4 commits)")[![petrparolek](https://avatars.githubusercontent.com/u/6066243?v=4)](https://github.com/petrparolek "petrparolek (3 commits)")[![PetrHudik](https://avatars.githubusercontent.com/u/560450?v=4)](https://github.com/PetrHudik "PetrHudik (1 commits)")[![GEp1c](https://avatars.githubusercontent.com/u/16386245?v=4)](https://github.com/GEp1c "GEp1c (1 commits)")[![Creeperface01](https://avatars.githubusercontent.com/u/10363500?v=4)](https://github.com/Creeperface01 "Creeperface01 (1 commits)")[![ViPErCZ](https://avatars.githubusercontent.com/u/1502711?v=4)](https://github.com/ViPErCZ "ViPErCZ (1 commits)")

---

Tags

facebookloginnetteoauth2phpsdkphpsdkfacebooknetteoauth2login

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[joelbutcher/facebook-graph-sdk

Facebook SDK for PHP

42697.8k1](/packages/joelbutcher-facebook-graph-sdk)[edbizarro/laravel-facebook-ads

Facebook &amp; Instagram Ads for Laravel 5.6+

13629.4k](/packages/edbizarro-laravel-facebook-ads)[manychat/manychat-api

ManyChat API PHP library

1716.1k](/packages/manychat-manychat-api)

PHPackages © 2026

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