Skip to content

Instantly share code, notes, and snippets.

@mattrude
Last active Feb 9, 2021
Embed
What would you like to do?
A helper file to transmit locations from TheThingsNetwork to Traccar
<?php
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$id = $data["dev_id"];
$lat = $data["payload_fields"]["latitude"];
$lon = $data["payload_fields"]["longitude"];
$altitude = $data["payload_fields"]["altitude"];
if (isset($id)) {
if (isset($lat)) {
if (isset($lon)) {
$page = file_get_contents("http://127.0.0.1:5055/?id=$id&lat=$lat&lon=$lon&alt=$altitude");
}
}
}
?>
<?php
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$id = $data["end_device_ids"]["device_id"];
$lat = $data["uplink_message"]["decoded_payload"]["latitude"];
$lon = $data["uplink_message"]["decoded_payload"]["longitude"];
$altitude = $data["uplink_message"]["decoded_payload"]["altitude"];
if (isset($id)) {
if (isset($lat)) {
if (isset($lon)) {
$page = file_get_contents("http://127.0.0.1:5055/?id=$id&lat=$lat&lon=$lon&alt=$altitude");
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment