API setting
API authorization
To access the API, you will need a user ID (app_id) and a signature (signature).
Calling different methods is carried out using queries on this template:
api.kadam.net?%action%.%method%?%params%
% action% - what are we turning to % method% - type of treatment get - get put - write post - update delete - delete % params% - request parameters required parameters% params% app_id - user id signature - signature
Example:
[GET] http://api.kadam.net/campaigns.get?app_id=%app_id%&signature=%signature%
or
[GET] http://api.kadam.net/campaigns?app_id=%app_id%&signature=%signature% [GET] - http access method
Signature (signature) is created using a temporary token (access_token), which can be obtained using the app_id and secret key parameters.
Parameters app_id (user ID) and the key "secret key" are available on request to support.
Getting a token:
[GET] http://api.kadam.net/auth.token?app_id=%app_id%&secret_key=%key% -> {“access_token”: “...”}
Generating signature for the [GET] method:
md5 ( %sort_params% . %access_token% ) %sort_params% - all parameters passed (except signature) are sorted by name
Example:
app_id=1&campaign_id=3… [PUT] http://api.kadam.net/campaigns?signature=%signature% +post fields -> %params%
Example for php. Getting a list of campaigns:
<? $your_secret_key = "jqhwekq8734quo37o498q3p498qp34"; $your_app_id = 1; $auth_url = "http://api.kadam.net/auth.token?app_id={$your_app_id}&secret_key={$your_secret_key}"; $auth = file_get_contents($auth_url); $auth = json_decode($auth, true); if ( !is_array( $auth ) || !isset( $auth['access_token'] ) ) { die( 'something wrong! ' . print_r( $res, true ) ); } $token = $auth['access_token']; $params = array( 'client_id' => $your_app_id, 'app_id' => $your_app_id, ); ksort( $params ); $result = array (); foreach( $params as $key => $value ) { $result[] = $key . '=' . urlencode( $value ); } $params = implode( '&', $result ); $signature = md5( $params . $token ); $campaign_url = 'http://api.kadam.net/ads.campaigns.get?' . $params . '&signature=' . $signature; $campaigns = file_get_contents($campaign_url); $campaigns = json_decode($campaigns, true); if ( !is_array( $campaigns ) || !isset( $campaigns['response'] ) ) { die( 'something wrong! ' . print_r( $campaigns, true ) ); } print_r($campaigns);
Campaign Statistics
To get campaign statistics, use the method ads.analytic.campaign.get
Parameters | Values | Optional attributes |
---|---|---|
campaign_id | campaign's id | int (numeric value), required parameter |
region_id | region's id: data.geo.regions.get | int (numeric value), required parameter |
period | The way data is grouped by date:
day — daily statistics; month - monthly statistics Temporary restrictions are set by parameters date_from and date_to |
required parameter, string |
date_from | The starting date of the statistics to display. Different date format is used for different parameter period values:
day: YYYY-MM-DD, example: 2011-09-27; month: YYYY-MM, example: 2011-09 |
required parameter, string |
date_to | The final date of the displayed statistics. Different date format is used for different parameter period values:
day: YYYY-MM-DD, example: 2011-09-27; month: YYYY-MM, example: 2011-09 |
required parameter, string |
Result:
Returns an object with data
{ response: { count: %total items% items: { shows clicks ctr cpm money } } }