1. Go to this page and download the library: Download automile/automile-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// import ile\Sdk\AutomileClient;useAutomile\Sdk\Config;
useAutomile\Sdk\Types;
useAutomile\Sdk\Models;
// path to the token
define('AUTOMILE_TOKEN', '/path/to/storage/automile-token.json');
// Automile account credentials// see also Sign Up section above
Config::setUsername('username@example.com');
Config::setPassword('*****');
Config::setApiClient('*****.automile.com');
Config::setApiSecret('*****');
// initialize the client from saved token// if the token is missing, a new one will be created using the credentials above
$client = AutomileClient::fromSavedToken(AUTOMILE_TOKEN);
// provide the path to the token storage file in case the new token is created, or old one refreshed
$client->saveToken(AUTOMILE_TOKEN);
// confirm everything's been set up correctly
$isValid = $client->validateToken();
var_dump($isValid);
$vehicles = $client->getVehicles();
$vehicleDetails = $client->getVehicleById(33553);
$vehicleStatus = $client->getStatusForVehicles();
$client->checkInToVehicle(new Models\Vehicle\CheckIn([
"ContactId" => 2,
"VehicleId" => 33553,
"DefaultTripType" => Types\TripType::AUTO, // Use the users schedule, place or other automation rules"CheckOutAtUtc" = (new \DateTime('now', 'UTC'))->add(new \DateInterval('P3D')) // Use to schedule future auto-checkout, leave empty for permanent check-in
}));
$newNotification = $client->createNotification(new Models\Trigger([
"IMEIConfigId" => 28288, // What is this ?// IMEIConfigId is today called DeviceId and is the device identifier // connected to the vehicle, you can get this id from the vehicle (GetVehicleById method)"TriggerType" => Types\TriggerType::ACCIDENT,
"DestinationType" => Types\DestinationType::SMS,
"DestinationData" => "+14158320378"
]));
$client->editNotification(new Models\Trigger([
"TriggerId" => 190914,
"IMEIConfigId => 28288, // See note above, this is the DeviceId
"TriggerType" => Types\TriggerType::ACCIDENT,
"DestinationType" = Types\DestinationType::SMS,
"DestinationData" = "+14158320378"
]));
$client->muteNotification(190913, 60*60); // mutes for 1 hour
$newPlace = $client->createPlace(new Models\Place([
"Name" => "My place",
"Description" => "My home",
"PositionPoint" => new Models\GeographicPosition([ "Latitude" => 37.445368, "Longitude" => -122.166608 ]),
"Radius" => 100, //metric meters//This will whenever the vehicle starts at this location set it to business"TripType" => Types\TripType::BUSINESS,
"TripTypeTrigger" => Types\TripTypeTriggerType::START,
"VehicleId" => 33553
]));
$client->editPlace(new Models\Place([
"PlaceId" => 11968,
"Name" => "My place - edited",
"PositionPoint" => new Models\GeographicPosition([ "Latitude" => 37.445368, "Longitude" => -122.166608 ])
]));
$client->deletePlace(11968);
$devices = $client->getDevices();
$deviceDetails = $client->getDeviceById(28288);
$newDevice = $client->createDevice(new Models\Device([
"IMEI" => "353466072332998",
"SerialNumber" => "6070763210",
"VehicleId" => 33553,
"IMEIDeviceType" = null// no need if you register a box
]));
$newFleet = $client->createFleet(new Models\Company([
"CreateRelationshipToContactId" => 2,
"Description" => "Some good description for the fleet",
"RegisteredCompanyName" => "My new fleet"
]));
$newVehicleGeofenceRelationship = $client->createVehicleGeofence(new Models\Vehicle\Geofence([
"GeofenceId" => 3276,
"VehicleId" => 33553,
// Restrict when this geofence should be valid from and to if needed"ValidFrom" => null,
"ValidTo" => null
]));
$dateTime = new \DateTime('now', new \DateTimeZone('UTC'));
$client->editVehicleGeofence(new Models\Vehicle\Geofence([
"VehicleGeofenceId" => 44251,
"ValidFrom" => $dateTime->format('Y-m-d'),
"ValidTo" => $dateTime->add(new \DateInterval('P7D'))->format('Y-m-d')
}));