Cleeng PHP SDK is a wrapper library that allows accessing Cleeng API in a convenient, object-oriented way. In the 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 an autoloader, please include the 'cleeng_api.php' file. That file will load the full PHP SDK library and prepare you to use Cleeng API. Check Tutorial - Protect your content. You can find there bunch of examples of how to include cleeng_api.


To start, you have to create the 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 [email protected] first:

$offerList = $cleengApi->listSingleOffers(array('publisherEmail' => '[email protected]'), 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');
// 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 know 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(

Did this page help you?