PHPackages                             vlechemin/facebook-batch-api - 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. vlechemin/facebook-batch-api

ActiveLibrary[API Development](/categories/api)

vlechemin/facebook-batch-api
============================

Use the Facebook SDK via batch requests without having to complexify the code with the pre-processing and post-processing phases.

v1.0.0(13y ago)01.2kMITPHPPHP &gt;=5.4.0

Since Apr 9Pushed 13y ago1 watchersCompare

[ Source](https://github.com/vlechemin/facebook-batch-api)[ Packagist](https://packagist.org/packages/vlechemin/facebook-batch-api)[ RSS](/packages/vlechemin-facebook-batch-api/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

facebook-batch-api
==================

[](#facebook-batch-api)

The goal is to use the [Facebook SDK](https://github.com/facebook/facebook-php-sdk) via [batch requests](https://developers.facebook.com/docs/reference/api/batch/) without having to complexify the code with the pre-processing and post-processing phases.

The trick is to use [reference](http://www.php.net/manual/en/language.references.php) to return a **temporary placeholder** and to replace the placeholder with the real result when needed.

Usage :

```
// use the api as usual, please note the &
$me = &$facebook->batchApi('/me');
$picture = &$facebook->batchApi('/me/picture', 'GET', [
    'type' => 'large',
    'return_ssl_resources' => 1,
]);

// execute the batch to fill $me and $picture with the real value
$facebook->processBatch();

// use the results
var_dump($me);
var_dump($picture);
```

Batch requests containing multiple methods
------------------------------------------

[](#batch-requests-containing-multiple-methods)

```
curl \
    -F 'access_token=…' \
    -F 'batch=[{ "method":"POST","relative_url":"me/feed","body":"message=Test status update&link=https://developers.facebook.com/"},{ "method":"GET","relative_url":"me/feed?limit=1"}]' \
    https://graph.facebook.com
```

The second parameter makes it easy to alternate methods.

```
$result1 = &$facebook->batchApi('me/feed', 'POST', [
    'message' => 'Test status update',
    'link' => 'https://developers.facebook.com/',
]);
$result2 = &$facebook->batchApi('me/feed', 'GET', [
    'limit' => 1,
]);
$facebook->processBatch();
```

Specifying dependencies between operations in the request
---------------------------------------------------------

[](#specifying-dependencies-between-operations-in-the-request)

```
curl \
   -F 'access_token=...' \
   -F 'batch=[{ "method":"GET","name":"get-friends","relative_url":"me/friends?limit=5",},{"method":"GET","relative_url":"?ids={result=get-friends:$.data.*.id}"}]' \
   https://graph.facebook.com/
```

A batch request can be named with the fourth parameter for later use.

```
$result1 = &$facebook->batchApi('me/friends', 'GET', [
    'limit' => 5,
], [
    'name' => 'get-friends',
]);
$result2 = &$facebook->batchApi('/', 'GET', [
    'ids' => '{result=get-friends:$.data.*.id}',
]);
$facebook->processBatch();
```

Uploading binary data
---------------------

[](#uploading-binary-data)

```
curl
     -F 'access_token=…' \
     -F 'batch=[{"method":"POST","relative_url":"me/photos","body":"message=My cat photo","attached_files":"file1"},{"method":"POST","relative_url":"me/photos","body":"message=My dog photo","attached_files":"file2"},]' \
     -F 'file1=@cat.gif' \
     -F 'file2=@dog.jpg' \
    https://graph.facebook.com
```

The method attachFile can be used to attach a file. The correspondance between the file name and the batch parameter is made internally.

```
$result1 = &$facebook->batchApi('me/photos', 'POST', [
    'message' => 'My cat photo',
], [
    'attached_files' => $facebook->attachFile('@cat.gif'),
]);
$result2 = &$facebook->batchApi('me/photos', 'POST', [
    'message' => 'My dog photo',
], [
    'attached_files' => $facebook->attachFile('@dog.jpg'),
]);
$facebook->processBatch();
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

4831d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/638315?v=4)[Vincent Lechemin](/maintainers/vlechemin)[@vlechemin](https://github.com/vlechemin)

---

Top Contributors

[![vlechemin](https://avatars.githubusercontent.com/u/638315?v=4)](https://github.com/vlechemin "vlechemin (3 commits)")

---

Tags

apifacebookbatch

### Embed Badge

![Health badge](/badges/vlechemin-facebook-batch-api/health.svg)

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

###  Alternatives

[kerox/messenger

PHP Library to interact with Facebook Messenger Platform

58318.7k1](/packages/kerox-messenger)[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22879.8k](/packages/m165437-laravel-blueprint-docs)[missael-anda/laravel-whatsapp

A Whatsapp Business Cloud API wrapper for Laravel.

678.0k](/packages/missael-anda-laravel-whatsapp)

PHPackages © 2026

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