PHPackages                             pitchanon/facebook-connect - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. pitchanon/facebook-connect

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

pitchanon/facebook-connect
==========================

A Laravel package for connecting to the Meta (Facebook) Graph API.

2.0.0(2w ago)264.3k11[4 issues](https://github.com/Pitchanon/Laravel4-FacebookConnect/issues)1GPL-3.0-or-laterPHPPHP ^8.2

Since Nov 22Pushed 2w ago3 watchersCompare

[ Source](https://github.com/Pitchanon/Laravel4-FacebookConnect)[ Packagist](https://packagist.org/packages/pitchanon/facebook-connect)[ Docs](https://github.com/Pitchanon/Laravel4-FacebookConnect)[ RSS](/packages/pitchanon-facebook-connect/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (7)Used By (1)

Facebook Connect for Laravel
----------------------------

[](#facebook-connect-for-laravel)

A small Laravel package that wraps the Meta (Facebook) Graph API for the common OAuth login flow, profile lookup, page posting, and "does this user like a page" checks. Works with Laravel 11 / 12 and PHP 8.2+.

The package talks to Graph API **v19.0** by default over plain HTTP (Guzzle), so it does not depend on the archived `facebook/graph-sdk` package.

### Version compatibility

[](#version-compatibility)

Package versionLaravelPHPFacebook SDKStatus`^2.0`11.x, 12.x^8.2Graph API v19 (Guzzle client)Current`^1.0`4.x, 5.x&gt;= 5.3Bundled Facebook PHP SDK 3.xMaintenanceThe legacy 1.x line is kept on the `1.x` branch for existing Laravel 4/5 users. Critical fixes may still be backported, but new features only land on `2.x`.

### Installation

[](#installation)

Latest (Laravel 11/12):

```
composer require pitchanon/facebook-connect:^2.0
```

Legacy (Laravel 4/5):

```
composer require pitchanon/facebook-connect:^1.0
```

The service provider and `FacebookConnect` facade are auto-discovered.

Publish the config file:

```
php artisan vendor:publish --tag=facebook-connect-config
```

Then set your Meta app credentials in `.env`:

```
FACEBOOK_APP_ID=your-app-id
FACEBOOK_APP_SECRET=your-app-secret
FACEBOOK_REDIRECT_URI=https://your-app.test/auth/facebook/callback
FACEBOOK_GRAPH_VERSION=v19.0
```

### Usage

[](#usage)

#### 1. Redirect the user to Facebook

[](#1-redirect-the-user-to-facebook)

```
use FacebookConnect;

Route::get('/auth/facebook', function () {
    $state = bin2hex(random_bytes(16));
    session(['fb_oauth_state' => $state]);

    return redirect(FacebookConnect::getLoginUrl(
        redirectUri: null, // falls back to config
        scopes: ['email', 'public_profile'],
        state: $state,
    ));
});
```

#### 2. Handle the callback

[](#2-handle-the-callback)

```
Route::get('/auth/facebook/callback', function (\Illuminate\Http\Request $request) {
    abort_unless(hash_equals(session('fb_oauth_state', ''), (string) $request->query('state')), 419);

    $token = FacebookConnect::getAccessTokenFromCode($request->query('code'));
    $longLived = FacebookConnect::getLongLivedToken($token['access_token']);

    $profile = FacebookConnect::getUser($longLived['access_token'], ['id', 'name', 'email']);

    // persist $profile + $longLived['access_token'] however you like
    return $profile;
});
```

#### 3. Post to a user or page feed

[](#3-post-to-a-user-or-page-feed)

```
FacebookConnect::postToFeed([
    'message' => 'Hello from Laravel!',
    'link'    => 'https://example.com',
], $accessToken, target: 'me');
```

For page posts, pass the page ID as `target` and use a page access token (available via `FacebookConnect::getUserAccounts($userAccessToken)`).

#### 4. Check if a user likes a page

[](#4-check-if-a-user-likes-a-page)

```
$likes = FacebookConnect::userLikesPage($userId, $pageId, $accessToken);
```

#### 5. Verify granted permissions

[](#5-verify-granted-permissions)

```
if (!FacebookConnect::hasGrantedPermissions($accessToken, ['email'])) {
    return redirect(FacebookConnect::getLoginUrl());
}
```

#### 6. Arbitrary Graph calls

[](#6-arbitrary-graph-calls)

```
FacebookConnect::get('/me/photos', ['access_token' => $accessToken, 'limit' => 5]);
FacebookConnect::post('/me/feed', ['message' => 'Hi', 'access_token' => $accessToken]);
```

### Errors

[](#errors)

All Graph API errors are thrown as `Pitchanon\FacebookConnect\Exceptions\FacebookConnectException` with the message and code returned by Meta.

### Migration notes (from the old Laravel 4 version)

[](#migration-notes-from-the-old-laravel-4-version)

- The bundled Facebook PHP SDK v3.2.2 has been removed — it has been unmaintained since 2018 and relied on deprecated endpoints (`fql.query`, `setExtendedAccessToken`, cookie-based sessions).
- `FacebookConnect::getUser($permissions, $url_app)` no longer exists as a one-shot "redirect or return profile" method. Use `getLoginUrl()` + `getAccessTokenFromCode()` + `getUser($accessToken)` instead — this is testable and does not `echo`/`exit` from inside the class.
- `offline_access` and `publish_stream` have been removed by Meta years ago. Use long-lived tokens (`getLongLivedToken()`) and the current publishing permissions (e.g. `pages_manage_posts` for page posting, subject to app review).
- The check-fan call no longer uses FQL (deprecated since 2016); it uses the `/{user-id}/likes/{page-id}` edge instead.

### License

[](#license)

GPL-3.0-or-later. See `LICENSE`.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance93

Actively maintained with recent releases

Popularity29

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 77.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 ~1134 days

Total

5

Last Release

18d ago

Major Versions

0.0.2 → 1.0.02014-02-07

1.x-dev → 2.0.02026-04-24

PHP version history (2 changes)0.0.1PHP &gt;=5.3.0

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/59284b554ab2c0e942e4fac734476680e3464d110024347c519166eb3aacf450?d=identicon)[popphoenix](/maintainers/popphoenix)

---

Top Contributors

[![Pitchanon](https://avatars.githubusercontent.com/u/5163902?v=4)](https://github.com/Pitchanon "Pitchanon (17 commits)")[![yrcjaya](https://avatars.githubusercontent.com/u/5592?v=4)](https://github.com/yrcjaya "yrcjaya (2 commits)")[![hpaul](https://avatars.githubusercontent.com/u/594424?v=4)](https://github.com/hpaul "hpaul (1 commits)")[![marcopeters](https://avatars.githubusercontent.com/u/8362663?v=4)](https://github.com/marcopeters "marcopeters (1 commits)")[![marekkapusta](https://avatars.githubusercontent.com/u/8248931?v=4)](https://github.com/marekkapusta "marekkapusta (1 commits)")

---

Tags

laravelfacebookoauthmetagraph-api

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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