2017 © Pedro Peláez
 

library php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

image

handsetdetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  • Thursday, September 21, 2017
  • by elricho
  • Repository
  • 3 Watchers
  • 3 Stars
  • 5,272 Installations
  • PHP
  • 3 Dependents
  • 1 Suggesters
  • 8 Forks
  • 2 Open issues
  • 23 Versions
  • 3 % Grown

The README.md

Build Status Latest Stable Version License, (*1)

PHP API Kit v4.0, implementing v4.0 of the HandsetDetection API.

API Kits can use our web service or resolve detections locally depending on your configuration., (*2)

Installation

Download the package directly from github or use composer., (*3)

{
    "require": {
      "handsetdetection/php-apikit": "4.*"
    }
}

Configuration

API Kit configuration files can be downloaded directly from Handset Detection., (*4)

  1. Login to your dashboard
  2. Click 'Add a Site'
  3. Configure your new site
  4. Grab the config file variables for your API Kit (from the site settings)
  5. Place the variables into the hdconfig.php file

Examples

Instantiate the HD4 object

// Using the default config file
require_once('HD4.php');
$hd = new HandsetDetection\HD4();

OR, (*5)

// Using a custom config file
require_once('HD4.php');
$hd = new HandsetDetection\HD4('/tmp/myCustomConfigFile.php');

List all vendors

if ($hd->deviceVendors()) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

List all device models for a vendor (Nokia)

if ($hd->deviceModels('Nokia')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

View information for a specific device (Nokia N95)

if ($hd->deviceView('Nokia','N95')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

What devices have this attribute ?

if ($hd->deviceWhatHas('network','CDMA')) {
    $data = $hd->getReply();
    print_r($data);
} else {
    print $hd->getError();
}

Basic device detection

This is the most simple detection call - http headers are picked up automatically., (*6)

if ($hd->deviceDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}

Manually set the http headers (user-agent etc..)

$hd->setDetectVar('user-agent','Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413');
$hd->setDetectVar('x-wap-profile','http://nds1.nds.nokia.com/uaprof/NN95-1r100.xml');
if ($hd->deviceDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}

Download the Full Ultimate Edition

Note : Increase the default timeout before downloading the archive., (*7)

$hd->setTimeout(500);
if ($hd->deviceFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded ".strlen($data)." bytes";
} else {
    print $hd->getError();
    print $hd->getRawReply();
}

Download the Community Ultimate Edition

$hd->setTimeout(500);
if ($hd->communityFetchArchive()) {
    $data = $hd->getRawReply();
    echo "Downloaded ".strlen($data)." bytes";
} else {
    print $hd->getError();
    print $hd->getRawReply();
}

Flexible Caching Options

Version 4.1.* includes APC(u), Memcache, Memcached and Redis caching options. For backwards compatibility if no option is set in the config file then it defaults to APC., (*8)

Note : Memcached and Memcached both have a default maximum object size of 1Mb which is too low. We recommend increasing this limit to at least 5Mb with the -I or --max-item-size= options., (*9)

Using Memcache

Include a the following cache configuration in your config file. Options represent any cache flags you would like to pass to the memcache::set call. See http://php.net/manual/en/memcache.set.php for more information., (*10)

$hdconfig['cache'] = array (
    'memcache' => array (
        'options' => 0,
        'servers' => array(
            'localhost' => '11211'
        )
    )
)

Using Memcached

Include a the following cache configuration in your config file. Options represent cache settings set via the setOption call : See http://php.net/manual/en/memcached.setoption.php for more information. Pass options as $option => $value in the options array., (*11)

$hdconfig['cache'] = array (
    'memcached' => array(
        'options' => array(),
        'servers' => array(
            array('localhost', '11211'),
        )
    )
);

If you're using cache connection pooling then pass the pool name as follows :, (*12)

$hdconfig['cache'] = array (
    'memcached' => array(
        'pool' => 'mypool',
        'options' => array(),
        'servers' => array(
            array('localhost', '11211'),
        )
    )
);

Using Predis

From version 4.1.11 we also have Redis as a caching option. Redis caching uses Predis, which you should include via composer. Use a caching config as follows:, (*13)

$hdconfig['cache'] = array (
    'redis' => array (
        'scheme' => 'tcp',
        'host'   => '127.0.0.1',
        'port'   => 6379
    )
);

Using PHPRedis

From version 4.1.12 we also have PhpRedis as a caching option, which uses the redis.so extension from https://github.com/phpredis/phpredis . connect_method can be connect or pconnect. pconnect connections also support a peristent_id., (*14)

Use a caching config as follows:, (*15)

$hdconfig['cache'] = array (
    'phpredis' => array (
        'connect_method' => 'pconnect',
        'host'   => '127.0.0.1',
        'port'   => 6379,
        'timeout' => 2.5,
        'persistent_id' => 'x'
    )
);

Extra Examples

Additional examples can be found in the examples.php file., (*16)

Getting Started with the Free usage tier and Community Edition

After signing up with our service you'll be on a free usage tier which entitles you to 20,000 Cloud detections (web service) per month, and access to our Community Edition for Ultimate (stand alone) detection. The archive for stand alone detection can be downloaded manually however its easiest to configure the API kit with your credentials and let the API kit do the heavy lifting for you. See examples above for how to do this., (*17)

Instructions for manually installing the archive are available at v4 API Ultimate Community Edition, Getting Started, (*18)

Unit testing

Unit tests use phpUnit and can be found in the tests directory., (*19)

API Documentation

See the v4 API Documentation., (*20)

API Kits

See the Handset Detection GitHub Repo., (*21)

Support

Let us know if you have any hassles (hello@handsetdetection.com)., (*22)

The Versions

21/09 2017

dev-master

9999999-dev https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

21/09 2017

4.1.13

4.1.13.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

11/04 2017

4.1.12

4.1.12.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

21/02 2017

4.1.11

4.1.11.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

22/12 2016

4.1.10

4.1.10.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

21/12 2016

4.1.9

4.1.9.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

14/12 2016

4.1.8

4.1.8.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

13/12 2016

4.1.7

4.1.7.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

24/11 2016

4.1.6

4.1.6.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

11/10 2016

4.1.5

4.1.5.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

05/10 2016

4.1.4

4.1.4.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

05/10 2016

4.1.3

4.1.3.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

11/07 2016

4.1.2

4.1.2.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

03/06 2016

4.1.1

4.1.1.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

24/05 2016

4.1.0

4.1.0.0 https://github.com/HandsetDetection/php-apikit

A library for stand alone or web service device detection, using HandsetDetection.com.

  Sources   Download

MIT

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

29/04 2016

dev-revert-28-revert-27-master

dev-revert-28-revert-27-master https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

29/04 2016

dev-revert-27-master

dev-revert-27-master https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

25/01 2016

4.0.2

4.0.2.0 https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

06/10 2015

4.0.1

4.0.1.0 https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

28/09 2015

4.0.x-dev

4.0.9999999.9999999-dev https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

28/09 2015

4.0.0

4.0.0.0 https://github.com/HandsetDetection/php-apikit

A device detection service by HandsetDetection.com

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

26/08 2014

3.2.0.x-dev

3.2.0.9999999-dev https://github.com/HandsetDetection/php-apikit

An handset detection service

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent

26/08 2014

3.2.0

3.2.0.0 https://github.com/HandsetDetection/php-apikit

An handset detection service

  Sources   Download

commercial

The Requires

  • php >=5.2.4

 

The Development Requires

device detection user-agent