2017 © Pedro Peláez
 

library adback-sdk-php

sdk php to call AdBack api

image

adback/adback-sdk-php

sdk php to call AdBack api

  • Thursday, June 28, 2018
  • by gignonje
  • Repository
  • 2 Watchers
  • 0 Stars
  • 5,241 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 20 Versions
  • 20 % Grown

The README.md

Adback/ApiClient

Scrutinizer Code Quality Code Coverage Build Status Latest Stable Version Total Downloads License, (*1)

This PHP library will call the AdBack API and will generate the JavaScript tag that should be placed on all the pages., (*2)

See the AdBack website for more informations., (*3)

See the AdBack documentation for an installation guide., (*4)

Usage

Both the Query and Generators will need a driver which implements the ScriptCacheInterface to work., (*5)

A driver for Redis is already available., (*6)

Usage Exemple

Installation

Use composer to install the lib :, (*7)

    composer require adback/adback-sdk-php

Usage with Redis

Query the api

First you need to query the api to warmup the cache in a Redis data store :, (*8)

    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();

Generate the scripts

In your page, preferably in the <head>, use the generator to create the script :, (*9)

    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();

You could do the same to create the other scripts by using the appropriate generators., (*10)

Usage with MySQL

Create the table

To create the table used to store the data in MySQL, run the query:, (*11)

    CREATE TABLE adback_cache_table(our_key varchar(255), our_value varchar(255));

With the PDO driver

Query the api

First you need to query the api to warmup the cache in a Mysql table :, (*12)

    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();
Generate the scripts

In your page, preferably in the <head>, use the generator to create the script :, (*13)

    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();

You could do the same to create the other scripts by using the appropriate generators., (*14)

With the Mysqli driver

Query the api

First you need to query the api to warmup the cache in a Mysql table :, (*15)

    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();
Generate the scripts

In your page, preferably in the <head>, use the generator to create the script :, (*16)

    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();

You could do the same to create the other scripts by using the appropriate generators., (*17)

Usage with Full script save and Redis

Query the api

First you need to query the full script api to warmup the cache in a Redis data store :, (*18)

    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();

Generate the code

In your page, use the generator to create the code :, (*19)

    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();

You could do the same to create the other scripts by using the appropriate generators., (*20)

Usage with Full script save and Redis with predis/predis

Query the api

First you need to query the full script api to warmup the cache in a Redis data store :, (*21)

    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();

Generate the code

In your page, use the generator to create the code :, (*22)

    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();

You could do the same to create the other scripts by using the appropriate generators., (*23)

The Versions

28/06 2018

dev-master

9999999-dev

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

28/06 2018

v2.5.0

2.5.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

03/05 2018

v2.4.0

2.4.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

01/02 2018

v2.3.0

2.3.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

11/09 2017

v2.2.0

2.2.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

21/07 2017

v2.1.0

2.1.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

13/07 2017

v2.0.0

2.0.0.0

sdk php to call AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

29/05 2017

v1.9.1

1.9.1.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

24/05 2017

v1.9.0

1.9.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

24/05 2017

v1.8.0

1.8.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

23/05 2017

v1.7.0

1.7.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

18/05 2017

v1.6.0

1.6.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

31/03 2017

v1.5.0

1.5.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

27/03 2017

v1.4.2

1.4.2.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

23/03 2017

v1.4.1

1.4.1.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

23/03 2017

v1.4.0

1.4.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

14/03 2017

v1.3.0

1.3.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

13/03 2017

v1.2.0

1.2.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.3

 

The Development Requires

by Nicolas Thal

19/01 2017

v1.1.0

1.1.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nicolas Thal

10/01 2017

v1.0.0

1.0.0.0

A php lib to call the AdBack api

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nicolas Thal