![Ezeio AAC Скачать руководство пользователя страница 84](http://html.mh-extra.com/html/ezeio/aac/aac_user-manual_2458291084.webp)
Verifying the validity of the data
Each call from the ezeio
™
system will include a HTTP header value called
X-HASH. The value of this header is the MD5 sum of the full JSON data
with the ezeio
™
read passcode added to the end. If the receiving service has
knowledge of the read passcode, it can easily verify that the data comes from
a valid source by checking this hash against the received data.
An example in PHP is below.
<?php
define("READPASS", "verysecretpasscode");
$json = file_get_contents('php://input');
if(!isset($_SERVER["HTTP_X_HASH"]))
die("ERROR: Missing hash");
if(md5($json . READPASS) != $_SERVER["HTTP_X_HASH"])
die("ERROR: Hash mismatch");
if(($data = json_decode($json, true)) == NULL)
die("ERROR: Invalid payload");
foreach($data["data"] as $sample) {
// process the sample here
$lastprocessed = $sample["time"];
}
// return the timestamp of the last processed sample
$r = array("result" => $lastprocessed);
print( json_encode($r) );
?>
For simplicity, this example has passcode hardcoded, but the user may
support multiple ezeios with unique passcodes by retrieving the ezeio serial
number from the JSON data before checking the hash validity.
Page 84 of 121
Содержание AAC
Страница 1: ...ezeio user manual Manual version 170314 ezeio models AAC AAF Page 1 of 121 ...
Страница 72: ...Page 72 of 121 ...