Download the PHP package facebook/php-ads-sdk without Composer

On this page you can find all versions of the php package facebook/php-ads-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.


After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

All versions of php-ads-sdk with dependencies

Informations about the package php-ads-sdk

Facebook Business SDK for PHP

Packagist License Build Status Scrutinizer Scrutinizer Coverage


The Facebook Business SDK is a one-stop shop to help our partners better serve their businesses. Partners are using multiple Facebook API's to server the needs of their clients. Adopting all these API's and keeping them up to date across the various platforms can be time consuming and ultimately prohibitive. For this reason Facebook has developed the Business SDK bundling many of its APIs into one SDK to ease implementation and upkeep. The Business SDK is an upgraded version of the Marketing API SDK that includes the Marketing API as well as many Facebook APIs from different platforms such as Pages, Business Manager, Instagram, etc.

Quick Start

Business SDK Getting Started Guide


Register An App

To get started with the SDK, you must have an app registered on

To manage the Marketing API, please visit your App Dashboard and add the Marketing API product to your app.

IMPORTANT: For security, it is recommended that you turn on 'Require App Secret' in your app's Settings->Advanced page.

Obtain An Access Token

When someone connects with an app using Facebook Login and approves the request for permissions, the app obtains an access token that provides temporary, secure access to Facebook APIs.

An access token is an opaque string that identifies a User, app, or Page.

For example, to access the Marketing API, you need to generate a User access token for your app and ask for the ads_management permission; to access Pages API, you need to generate a Page access token for your app and ask for the manage_page permission.

Refer to our Access Token Guide to learn more.

For now, we can use the Graph Explorer to get an access token.


The Facebook Business SDK requires PHP 5.6 or greater.


The Facebook Business SDK uses composer to manage dependencies. Visit the composer documentation to learn how to install composer.

Add the following to your composer.json file:

then install it through composer:

This SDK and its dependencies will be installed under ./vendor.


This repository is written following the psr-4 autoloading standard. Any psr-4 compatible autoloader can be used.


Api main class

The FacebookAds\Api object is the foundation of the Business SDK which encapsulates a FacebookAds\Session and is used to execute requests against the Graph API.

To instantiate an Api object you will need a valid access token:

Once instantiated, the Api object will allow you to start making requests to the Graph API.

Fields names

Due to the high number of field names in the Graph API existing objects, in order to facilitate your code maintainability, enum-like classes are provided. These files are stored under the FacebookAds/Object/Fields directory. You can access object properties in the same manner you would usually do in php:

or using the enums:

Object classes

Facebook Ads entities are defined as classes under the FacebookAds/Object directory.

Read Objects

For some objects, the Ads API doesn't return all available fields by default. The first argument of the object's read method is an array of field names to be requested.

Requesting an high number of fields may cause the response time to visibly increase, you should always request only the fields you really need.

Create Objects

Update Objects

Delete Objects


Since the release of the Facebook Graph API 2.0, pagination is handled through cursors. Here cursors are defined as in \FacebookAds\Cursor. Cursors are generally returned from connection methods:

Implicit Fetching

Whenever all object connected to a parent are required (carelessly from the number of HTTP requests) implicit fetching can help reducing the amount of code required. If cursor has Implicit Fetching enabled, while iterating (foreach, Cursor::next(), Cursor::prev()) the page end is reached, the SDK will automatically fetch and append a new page, until cursor end. Implicit Fetching will make you lose control of the number of HTTP request that will be sent and, for this reason, is disabled by default. Implicit Fetching can be enabled for a specific cursor:

Or globally:

Reverse Iterations

Cursors are bi-directional, and can be iterated in reverse order:


The 'test' folder contains the test cases. These are logically divided in unit and integration tests. Integration tests require an active Facebook Ad Account, a Facebook Application and a valid Access Token.

Note: we are currently unable to securely and reliably run integration tests on a public CI system. Our integrations with Travis and Scrutinizer (including badges at the top of this file) include only unit tests.

Install dependencies

From the root folder run:

Execute unit tests only

To run tests individually (be sure not to be pointing to an integration test file):

Execute all tests (unit + integration)

Setup your integration config:

1 - Copy the config file template.

2 - Edit test/config.php with your informations.


To run tests individually:


If this SDK is not working as expected, it may be either a SDK issue or API issue.

This can be identified by constructing a raw cURL request and seeing if the response is as expected

for example:

When running this code, this cURL request will be printed to the console as:

SDK Codegen

Our SDK is autogenerated from SDK Codegen. If you want to learn more about how our SDK code is generated, please check this repository.


Since we want to handle bugs more efficiently, we've decided to close issue reporting in Github and move to our dedicated bug reporting channel. If you encounter a bug with Business SDK (PHP), please report the issue at our developer bug reporting channel.

Requires guzzlehttp/guzzle Version ^6.5 || ^7.0

The package facebook/php-ads-sdk contains the following files

Loading the files please wait ....