2017 © Pedro Peláez
 

library appnexusapi

Interface for accessing the AppNexus read-only API

image

swco/appnexusapi

Interface for accessing the AppNexus read-only API

  • Wednesday, May 25, 2016
  • by garoevans
  • Repository
  • 5 Watchers
  • 2 Stars
  • 310 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 24 % Grown

The README.md

AppNexus Read-Only API

Latest Stable Version Build Status License, (*1)

Installation

This library requires PHP 5.3 or later, and is installable and autoloadable via Composer as swco/appnexusapi., (*2)

Getting Started

The examples below show a few different ways you can access data., (*3)

When accessing data through the helper get* methods the request is sent straight away and returns an array of objects., (*4)

When using the get($service, $reset = true) method you can continue to apply filtering before calling send(). With send() you also get the Response object returned rather than a regular array. This gives access to a few more methods like getStatus() and getStartElement()., (*5)

The second param passed to get() allows you to reset all the filters (default action). Passing false will stop reset() being called., (*6)

use \SWCO\AppNexusAPI\Request;

$request = new Request("username", "password");

// Get category ID 1 and 7
$categories = $request->whereId(array(1, 7))->getCategories();

// Get category ID 5
$category = $request->getCategory(5);

// Get all brands update since June 2014
$brands = $request->get(Request::SERVICE_BRAND)->since(new DateTime('June 2014'))->send();
echo $brands->getStatus();// OK

// Domain Audit Statuses are a bit different as they needs some post data
$domainAuditStatus = $request->getDomainAuditStatuses(array('google.com'));

All services' parameters default to their falsey value;, (*7)

string = '';
int = 0;
bool = false;
array = array();
float = 0.0;

The only exception to this rule is params that should be an object, if unset these will return null;, (*8)

object = null;

Advanced

Some services (currently Brand) have their own special filter, this is accompanied with a Request wrapper;, (*9)

use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\BrandRequest;

$request = new Request("username", "password");

$brand = BrandRequest::newFromRequest($request);

$brand->simple();

...

This allows for extra functionality such as access to the simple() method above that removes the num_creatives data making the API call a lot faster., (*10)

You can also send the simple flags through the helper functions getBrand() and getBrands();, (*11)

use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\BrandRequest;

$request = new Request("username", "password");

$brand = BrandRequest::newFromRequest($request);

$simple = true;
$brand->getBrand(1, $simple);

Auth

For heavier usage it is worth storing the token for re-use*. The token doesn't change and the library handles re-authing when needed., (*12)

*The token does change occasionally. If an old token is stored in the config the request will re-auth getting a correct token. There is currently no way of reporting this., (*13)

Auth can be handled via the request object or using the Auth object directly;, (*14)

use \SWCO\AppNexusAPI\Request;

$request = new Request("username", "password");
$token = $request->auth();

// Store $token somewhere
use \SWCO\AppNexusAPI\Auth;
use \Guzzle\Http\Client;
use \SWCO\AppNexusAPI\Request;
use \SWCO\AppNexusAPI\Exceptions\NoAuthException;

$auth = new Auth();
$auth->setClient(new Client(Request::APP_NEXUS_API_URL));
try {
    $token = $auth->auth('username', 'password');
} catch (NoAuthException $e) {
    $token = null;
}

if ($token) {
    // Store $token somewhere
}

DataPool

Generally the API is limited to 100 results per request. There is a DataPool object available to get all or a specific number of results by making multiple requests;, (*15)

use SWCO\AppNexusAPI\DataPool;
use SWCO\AppNexusAPI\Request;

$request = new Request('username', 'password');
$request->get(Request::SERVICE_DEVICE_MAKE);

$dataPool = new DataPool();

$data = $dataPool->getAll($request); // Gets all Device Make items

$data = $dataPool->get($request, 250); // Gets the first 250 results of the Device Make items.

$request->offsetBy(250);

$data = $dataPool->get($request, 250); // Gets items 250 - 500.

The Versions

25/05 2016

dev-master

9999999-dev

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

27/10 2015

v1.4.2

1.4.2.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

26/10 2015

v1.4.1

1.4.1.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

22/10 2015

v1.4.0

1.4.0.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

19/10 2015

v1.3.1

1.3.1.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

15/10 2015

v1.3.0

1.3.0.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

08/09 2014

v1.2.1

1.2.1.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

21/07 2014

v1.2.0

1.2.0.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

13/06 2014

v1.1.0

1.1.0.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gareth Evans

10/06 2014

v1.0.1

1.0.1.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

by Gareth Evans

09/06 2014

v1.0.0

1.0.0.0

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

by Gareth Evans

09/06 2014

v1.0.0-beta

1.0.0.0-beta

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

by Gareth Evans

06/06 2014

v1.0.0-alpha.2

1.0.0.0-alpha2

Interface for accessing the AppNexus read-only API

  Sources   Download

MIT

The Requires

 

by Gareth Evans

06/06 2014

v1.0.0-alpha

1.0.0.0-alpha

AppNexus Read-Only API

  Sources   Download

MIT

The Requires