This is how I updated the changes via the API (along with some simple error checking). I am also working on a (small, but growing) PHP library for accessing the Gauges API. I will post a link to it later when I am done.
<?php
$main_account_token = "YOUR_API_TOKEN";
$new_info = array("first_name" => "Emilio");
$my_new_info = $this->set_gauges_info($main_account_token, $new_info);
echo "my_new_info<pre>"; var_dump($my_new_info); echo "</pre>";
if (is_numeric($my_new_info)) {
$error = $this->gauges_api_errors($my_new_info);
echo "ERROR: ".$error."<br />";
}
public function set_gauges_info($token="",$items=array()) {
//Only one item can be changed at a time
if (($token!="") && (count($items)==1)) {
$qry_str = "";
$values = count($items);
$count = 0;
foreach($items AS $a => $b) {
$qry_str .= $a.'='.$b;
$count++;
if ($count<$values) { $qry_str .= ","; }
}
$headers = array("X-Gauges-Token: ".$token);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $qry_str);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data);
}
return false;
}
public function gauges_api_errors($error=0) {
$result = "";
switch($error) {
case -1:
$result = "Token/API Client description is empty.";
break;
case -2:
$result = "1) Token/API Client description is empty, or 2) API client name error.";
break;
case -3:
$result = "API client name not present.";
break;
case -4:
$result = "API client key not present.";
break;
case -5:
$result = "Token/API Client key is empty.";
break;
default:
break;
}
return $result;
}
?>