PHP code example of adback / adback-sdk-php

1. Go to this page and download the library: Download adback/adback-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adback / adback-sdk-php example snippets


    composer 

    use Adback\ApiClient\Client\Client;
    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);

        $query = new ScriptUrlQuery($client, $redisCache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Generator\AnalyticsScriptGenerator;

    function generateAnalyticsScript()
    {
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);
        $generator = new AnalyticsScriptGenerator($redisCache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();

    use Adback\ApiClient\Client\Client;
    use Adback\ApiClient\Driver\PdoScriptCache;
    use Adback\ApiClient\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $connection = new \PDO('mysql:host=your-database-host;dbname=your-database;charset=utf8', 'login', 'password');
        $cache = new PdoScriptCache($connection);

        $query = new ScriptUrlQuery($client, $cache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Adback\ApiClient\Generator\AnalyticsScriptGenerator;
    use Adback\ApiClient\Driver\PdoScriptCache;


    function generateAnalyticsScript()
    {
        $connection = new \PDO('mysql:host=your-database-host;dbname=your-database;charset=utf8', 'login', 'password');
        $cache = new PdoScriptCache($connection);
        $generator = new AnalyticsScriptGenerator($cache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();

    use Adback\ApiClient\Client\Client;
    use Adback\ApiClient\Driver\MysqliScriptCache;
    use Adback\ApiClient\Query\ScriptUrlQuery;

    function createApiCache()
    {
        $client = new Client();
        $connection = new \mysqli('your-database-host', 'login', 'password', 'your-database');
        $cache = new MysqliScriptCache($connection);

        $query = new ScriptUrlQuery($client, $cache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Adback\ApiClient\Generator\AnalyticsScriptGenerator;
    use Adback\ApiClient\Driver\PdoScriptCache;


    function generateAnalyticsScript()
    {
        $connection = new \mysqli('your-database-host', 'login', 'password', 'your-database');
        $cache = new MysqliScriptCache($connection);
        $generator = new AnalyticsScriptGenerator($cache);

        return $generator->generate();
    }

    echo generateAnalyticsScript();

    use Adback\ApiClient\Client\Client;
    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Query\FullScriptQuery;

    function createApiCache()
    {
        $client = new Client();
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);

        $query = new FullScriptQuery($client, $redisCache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Generator\AnalyticsCodeGenerator;

    function generateAnalyticsCode()
    {
        $redis = new \Redis();
        $redis->connect('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);
        $generator = new AnalyticsCodeGenerator($redisCache);

        return $generator->generate();
    }

    echo generateAnalyticsCode();

    use Adback\ApiClient\Client\Client;
    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Query\FullScriptQuery;
    use Predis\Client as Predis;

    function createApiCache()
    {
        $client = new Client();
        $redis = new \Predis('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);

        $query = new FullScriptQuery($client, $redisCache, 'your-token');
        $query->execute();
    }

    createApiCache();

    use Adback\ApiClient\Driver\RedisScriptCache;
    use Adback\ApiClient\Generator\AnalyticsCodeGenerator;
    use Predis\Client as Predis;

    function generateAnalyticsCode()
    {
        $redis = new \Predis('127.0.0.1');
        $redisCache = new RedisScriptCache($redis);
        $generator = new AnalyticsCodeGenerator($redisCache);

        return $generator->generate();
    }

    echo generateAnalyticsCode();