admitad-api
A PHP wrapper around the Admitad API
Install
Install http://getcomposer.org/ and run the following command:
php composer.phar require admitad/api dev-master
Examples
Request access token
$api = new \Admitad\Api\Api()
$response = $api->authorizeByPassword($clientId, $clientPassword, $scope, $username, $password);
$result = $api->getArrayResultFromResponse($response);
$api = new \Admitad\Api\Api();
$authorizeUrl = $api->getAuthorizeUrl($clientId, $redirectUri, $scope);
$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);
Refresh token
$response = $api->refreshToken($clientId, $clientSecret, $refreshToken);
$result = $api->getArrayResultFromResponse($response);
Methods
There are 2 common methods to communicate with api:
$api = new \Admitad\Api\Api($accessToken);
$api->get($path, $params);
$api->post($path, $params);
$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)
$iterator = $api->getIterator('/advcampaigns/', array(
'order_by' => 'id'
));
foreach ($iterator as $campaign) {
}