Cleeng PHP SDK

Cleeng PHP SDK is a wrapper library that allows accessing Cleeng API in convenient, object oriented way. In next steps you can read how to download, install and use Cleeng PHP SDK.


Cleeng PHP SDK required PHP version 5.2 (or above) and CURL extension.


Cleeng PHP SDK is hosted on GitHub.


If you don't use autoloader, please include cleend_api.php file. That file will load full PHP SDK library, and prepare you to use Cleeng API. Check Tutorial 1 - protect your content. You can find there bunch of examples how to include cleeng_api.


To start, you have to create Cleeng_Api object.

$cleengApi = new Cleeng_Api();

By default SDK doesn't require any configuration. You may want to switch it to sandbox mode during tests:


When Cleeng_Api class is instantiated, you can start using the API! As an example, we'll list single offers from first:

$offerList = $cleengApi->listSingleOffers(array('publisherEmail' => ''), 0, 20);
foreach ($offerList as $offer) {
    echo $offer->title, "<br />\n";


Most of Cleeng API functions require either customerToken or publisherToken parameter to be specified. PHP SDK will try to read customer token from cookie (it is created on your domain by Javascript API after customer purchases or logs in).

Publisher token must be set explicitly:


Batch mode

You can bundle max 50 API calls into 1 http-request.

$cleengApi->setBatchMode(true);  // enable batch mode
$offer = $cleengApi->getSingleOffer('A123123123');        // stack some API calls...
$status1 = $cleengApi->getAccessStatus('A123123123');
$status2 = $cleengApi->getAccessStatus('S789789789');
$cleengApi->commit(); // make actual request

// now properties are available:
if ($status1->accessGranted || $status2->accessGranted) {
     // ...


In case of any troubles related to connection or environment settings, what you should now is:

  • Cleeng PHP SDK uses Curl extension to connect with Cleeng API,
  • connection timeout is set 10s.

If needed, you can set your own Curl settings using:


For instance, to increase default timeout, you can use:

$options = array(