In ClickMeter campaigns represent a group of datapoints (tracking links or tracking pixels).
Following is an example in PHP code on how to create a new group (campaign).
<?php
$url = 'http://apiv2.clickmeter.com/groups';
$cm_api_key = ''; // add your api key here
//set POST variables
$fields = array(
'name' => 'testGroup',
'notes' => 'Little description...'
);
$fields_json = json_encode($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Clickmeter-Authkey: '.$cm_api_key, 'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_json);
//execute post
$result = curl_exec($ch);
if($result === false){
echo "Error Number:".curl_errno($ch)."<br>";
echo "Error String:".curl_error($ch);
}
//close connection
curl_close($ch);
?>
0 Comments