PHPackages                             nickdnk/graph-sdk - 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. [API Development](/categories/api)
4. /
5. nickdnk/graph-sdk

ActiveLibrary[API Development](/categories/api)

nickdnk/graph-sdk
=================

Facebook SDK for PHP 8+

8.0.1(8mo ago)452.0M↓10.9%255proprietaryPHPPHP ^8.1CI passing

Since May 9Pushed 5mo ago4 watchersCompare

[ Source](https://github.com/nickdnk/php-graph-sdk)[ Packagist](https://packagist.org/packages/nickdnk/graph-sdk)[ Docs](https://github.com/nickdnk/php-graph-sdk)[ RSS](/packages/nickdnk-graph-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (11)Used By (5)

Facebook SDK for PHP
====================

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

[![Build Status](https://github.com/nickdnk/php-graph-sdk/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/nickdnk/php-graph-sdk/actions/workflows/test.yml)[![Latest Stable Version](https://camo.githubusercontent.com/4dff37638d787f54aa78bbf5fa614a3952a79c17aeb522478098c05d7c267d4d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6e69636b646e6b2f7068702d67726170682d73646b3f7374796c653d666c6174266c6162656c3d76657273696f6e)](https://packagist.org/packages/nickdnk/graph-sdk)[![Downloads](https://camo.githubusercontent.com/e58034e1eee3d3424cccb13c8f68de9f3d3586c06a9adf276ff202deddf841c8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e69636b646e6b2f67726170682d73646b3f6c6162656c3d446f776e6c6f616473)](https://packagist.org/packages/nickdnk/graph-sdk)

### This is an unofficial version of Facebook's PHP SDK designed for PHP 8+. It is being maintained and tested against the newest PHP versions. You can use this in place of version `5.x` of Facebook's deprecated `facebook/graph-sdk` package.

[](#this-is-an-unofficial-version-of-facebooks-php-sdk-designed-for-php-8-it-is-being-maintained-and-tested-against-the-newest-php-versions-you-can-use-this-in-place-of-version-5x-of-facebooks-deprecated-facebookgraph-sdk-package)

### PHP 8.1 is required.

[](#php-81-is-required)

This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app.

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

[](#installation)

The Facebook PHP SDK can be installed with [Composer](https://getcomposer.org/). Run this command:

```
composer require nickdnk/graph-sdk
```

By default, the request will be made via a `Facebook\HttpClients\FacebookHttpClientInterface`. The default implementation depends on the available PHP extension/packages. In order of priority:

1. Package `guzzlehttp/guzzle` (v6 and v7 only): `Facebook\HttpClients\FacebookGuzzleHttpClient`
2. ext-curl: `Facebook\HttpClients\FacebookCurlHttpClient`
3. Fallback: `Facebook\HttpClients\FacebookStreamHttpClient`

Usage
-----

[](#usage)

Simple GET example of a user's profile.

```
require_once __DIR__ . '/vendor/autoload.php';

use Facebook\Facebook;
use Facebook\GraphNodes\GraphUser;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;

$fb = new Facebook([
  'app_id' => '{app-id}',
  'app_secret' => '{app-secret}',
  'default_graph_version' => 'v20.0',
  //'default_access_token' => '{access-token}', // optional
]);

// Use one of the helper classes to get a Facebook\Authentication\AccessToken entity.
//   $helper = $fb->getRedirectLoginHelper();
//   $helper = $fb->getJavaScriptHelper();
//   $helper = $fb->getCanvasHelper();
//   $helper = $fb->getPageTabHelper();

try {

  // If you provided a 'default_access_token', the '{access-token}' is optional.
  $response = $fb->get('/me', '{access-token}');

  // To decode the response to a PHP class, provide the class of the root node in the
  // response. You will have to match this manually based on the endpoint you
  // requested. Please do open a pull request if you want to add more types.

  /** @var GraphUser $me */
  $me = $response->getGraphNode(GraphUser::class);
  echo 'Logged in as ' . $me->getName() . PHP_EOL;
  echo 'User email is ' . $me->getEmail() . PHP_EOL;

} catch (FacebookResponseException $e) {

  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();

} catch (FacebookSDKException $e) {

  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();

}
```

Tests
-----

[](#tests)

1. [Composer](https://getcomposer.org/) is a prerequisite for running the tests. Install composer globally, then run `composer install` to install required files.
2. The tests can be executed by running this command from the root directory:

```
$ ./vendor/bin/phpunit
```

License
-------

[](#license)

Please see the [license file](https://github.com/facebook/php-graph-sdk/blob/master/LICENSE)for more information.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance66

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community34

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~195 days

Recently: every ~268 days

Total

9

Last Release

269d ago

Major Versions

6.0.3 → 7.0.12022-09-14

7.0.1 → 8.0.0-rc12025-03-20

PHP version history (2 changes)6.0.0PHP ^7.3 || ^8.0

8.0.0-rc1PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/980f8465e8c1fc6dc77f2d705d73594f704e2337604e96bde86c42de40bf9aac?d=identicon)[nickdnk](/maintainers/nickdnk)

---

Top Contributors

[![SammyK](https://avatars.githubusercontent.com/u/578780?v=4)](https://github.com/SammyK "SammyK (217 commits)")[![gfosco](https://avatars.githubusercontent.com/u/406732?v=4)](https://github.com/gfosco "gfosco (109 commits)")[![yguedidi](https://avatars.githubusercontent.com/u/1480128?v=4)](https://github.com/yguedidi "yguedidi (60 commits)")[![nickdnk](https://avatars.githubusercontent.com/u/8411314?v=4)](https://github.com/nickdnk "nickdnk (34 commits)")[![EmanueleMinotto](https://avatars.githubusercontent.com/u/417201?v=4)](https://github.com/EmanueleMinotto "EmanueleMinotto (14 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (13 commits)")[![teldosas](https://avatars.githubusercontent.com/u/10049633?v=4)](https://github.com/teldosas "teldosas (10 commits)")[![martinstuecklschwaiger](https://avatars.githubusercontent.com/u/1061218?v=4)](https://github.com/martinstuecklschwaiger "martinstuecklschwaiger (8 commits)")[![tlshaheen](https://avatars.githubusercontent.com/u/385724?v=4)](https://github.com/tlshaheen "tlshaheen (6 commits)")[![tolbon](https://avatars.githubusercontent.com/u/768394?v=4)](https://github.com/tolbon "tolbon (5 commits)")[![danielegrosso](https://avatars.githubusercontent.com/u/5718544?v=4)](https://github.com/danielegrosso "danielegrosso (5 commits)")[![hardik-bhadani-git](https://avatars.githubusercontent.com/u/6279697?v=4)](https://github.com/hardik-bhadani-git "hardik-bhadani-git (4 commits)")[![alex-orbit](https://avatars.githubusercontent.com/u/192304739?v=4)](https://github.com/alex-orbit "alex-orbit (3 commits)")[![brainexe](https://avatars.githubusercontent.com/u/1894271?v=4)](https://github.com/brainexe "brainexe (3 commits)")[![guidolodetti](https://avatars.githubusercontent.com/u/7063023?v=4)](https://github.com/guidolodetti "guidolodetti (3 commits)")[![keyvanakbary](https://avatars.githubusercontent.com/u/717129?v=4)](https://github.com/keyvanakbary "keyvanakbary (3 commits)")[![phaizullin](https://avatars.githubusercontent.com/u/884354?v=4)](https://github.com/phaizullin "phaizullin (3 commits)")[![qpautrat](https://avatars.githubusercontent.com/u/1844413?v=4)](https://github.com/qpautrat "qpautrat (3 commits)")[![rdohms](https://avatars.githubusercontent.com/u/94331?v=4)](https://github.com/rdohms "rdohms (3 commits)")[![rpalladino](https://avatars.githubusercontent.com/u/1429151?v=4)](https://github.com/rpalladino "rpalladino (3 commits)")

---

Tags

sdkfacebook

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nickdnk-graph-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/nickdnk-graph-sdk/health.svg)](https://phpackages.com/packages/nickdnk-graph-sdk)
```

PHPackages © 2026

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