2017 © Pedro Peláez
 

library api

Admitad api library

image

admitad/api

Admitad api library

  • Wednesday, July 11, 2018
  • by Sirian
  • Repository
  • 3 Watchers
  • 17 Stars
  • 39,038 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 17 Forks
  • 1 Open issues
  • 5 Versions
  • 6 % Grown

The README.md

admitad-api

A PHP wrapper around the Admitad API, (*1)

Install

Install http://getcomposer.org/ and run the following command:, (*2)

php composer.phar require admitad/api dev-master

Examples

Request access token

  • By username / password
$api = new \Admitad\Api\Api()
$response = $api->authorizeByPassword($clientId, $clientPassword, $scope, $username, $password);
$result = $api->getArrayResultFromResponse($response); // or $response->getArrayResult();
  • OAuth2
// 1 step - get oauth authorization url
$api = new \Admitad\Api\Api();
$authorizeUrl = $api->getAuthorizeUrl($clientId, $redirectUri, $scope);
// redirect user to authorizeUrl


// 2 step - request access token by OAuth2 code returned from authorization url
$response = $api->requestAccessToken($clientId, $clientSecret, $code, $redirectUri);
$result = $api->getArrayResultFromResponse($response);
  • Signed Request (for applications on apps.admitad.com)
$api = new \Admitad\Api\Api();
$data = $api->parseSignedRequest($signedRequest, $clientSecret);
// this method throws Admitad\Api\Exception\InvalidSignedRequestException when $signedRequest is invalid

Refresh token

$response = $api->refreshToken($clientId, $clientSecret, $refreshToken);
$result = $api->getArrayResultFromResponse($response);

Methods

There are 2 common methods to communicate with api:, (*3)

$api = new \Admitad\Api\Api($accessToken);

$api->get($path, $params);
$api->post($path, $params);

//for example
$response = $api->get('/advcampaigns/', array(
    'limit' => 20,
    'offset' => 0
));

$result = $api->getArrayResultFromResponse($response);

Paginated-result methods can be iterated in this way (instead of manually call methods with different offsets), (*4)

$iterator = $api->getIterator('/advcampaigns/', array(
    'order_by' => 'id'
));

foreach ($iterator as $campaign) {
    // do smth with campaign
}

The Versions

11/07 2018

dev-master

9999999-dev

Admitad api library

  Sources   Download

The Requires

 

The Development Requires

api admitad

11/07 2018

0.1.2

0.1.2.0

Admitad api library

  Sources   Download

The Requires

 

The Development Requires

api admitad

03/04 2018

0.1.1

0.1.1.0

Admitad api library

  Sources   Download

The Requires

 

The Development Requires

api admitad

30/03 2018

dev-new

dev-new

Admitad api library

  Sources   Download

The Requires

 

The Development Requires

api admitad

31/08 2016

0.1.0

0.1.0.0

Admitad api library

  Sources   Download

The Requires

 

The Development Requires

api admitad