wiki:Developer_Lib_PHP

MoosTrax Library for PHP

Source Download:  http://www.moostrax.com/static/php-moostrax.tar.gz

Usage

demo.php

<?
require_once('MoosTrax.inc.php');
$api_key = "API_KEY";

$moostrax = new MoosTrax($api_key);

/* get devices */
$devices = $moostrax->getDevices();

/* print device info and current location */
foreach($devices as $device) {
    $device_info = $moostrax->getDeviceInfo($device);
    
    echo "------------------------------\n";
    echo 'Name: ' . $device_info->{"device_name"} . "\n";
    echo 'ID: ' . $device_info->{"device_id"} . "\n";
    echo 'UTC Last Contact: ' . $device_info->{"last_contact"} . "\n";
    echo 'UTC Date Added: ' . $device_info->{"date_added"} . "\n";
    
    $location = $moostrax->getCurrentLocation($device);
    echo "Current Location: " . $location->{"latitude"} . ", " . $location->{"longitude"} . " - " . $location->{"date"} . "\n";
    
    $history = $moostrax->getHistory($device, "01/01/2009 00:00:00", "12/01/2009 00:00:00");

    echo "History: " . count($history) . "\n";
    if(count($history) > 0) {
        $location = $history[0];
        echo "First history: " . $location->{"latitude"} . ", " . $location->{"longitude"} . " - " . $location->{"date"} . "\n";  
    }
}

?>