PHP code example of admitad / api

1. Go to this page and download the library: Download admitad/api 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/ */

    

admitad / api example snippets


$api = new Admitad\Api\Api()
$response = $api->authorizeByPassword($clientId, $clientPassword, $scope, $username, $password);
$result = $response->getResult(); // or $response->getArrayResult();

// 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 = $response->getResult();

$api = new Admitad\Api\Api();
$data = $api->parseSignedRequest($signedRequest, $clientSecret);
// this method throws Admitad\Api\Exception\InvalidSignedRequestException when $signedRequest is invalid

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

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

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

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

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

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

php composer.phar