Walker Tracker API Documentation
Back to API Documentation
API Example
Get a list of a walker's groups, group descriptions and averages
Fetch walker's groups
parse XML
API requests
http://walkertracker.com/api/ben.xml/groups
View the example - enter a username:
<?php //This function fetches data from Walker Tracker API using CURL function wt_api_request($username,$data_format,$method,$date_range="") { $api_url = "http://walkertracker.com/api/"; $api_request = $api_url . $username . "." . $data_format ."/".$method; if($date_range !="") { $api_request .= "/" . $date_range; } $ch = curl_init(); $timeout = 10; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $api_request); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $curl_contents = @(curl_exec($ch)); curl_close($ch); return $curl_contents; } //Using php function above, wt_api_request //get all groups data for this user, in xml $groups_data = wt_api_request(ben,"xml","groups"); if(strstr($groups_data,"xml")) { $xml = new SimpleXMLElement($groups_data); //check to see if an error was returned if($xml->error) { echo "
ERROR:
"; echo $xml->error; exit; } $n = count($xml->walker->group); $i=0; while ($i<$n) { foreach ($xml->walker->group[$i] as $key => $value) { if($key=="name"){ echo "Group Name: $value
";} if($key=="description"){ echo "Description: $value
";} if($key=="number_of_members"){ echo "Number of Members: $value
";} if($key=="average"){ echo "Average: $value
";} } echo "
"; $i++; } } ?>