38 lines
712 B
PHP
38 lines
712 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
require_once 'config.php';
|
|
|
|
|
|
$device = $_REQUEST['device'] ?? null;
|
|
|
|
if (is_null($device)) {
|
|
die(json_encode([
|
|
'status' => 'error',
|
|
'message' => $msg
|
|
], JSON_UNESCAPED_UNICODE));
|
|
}
|
|
|
|
// 不能超过 128
|
|
if (strlen($device) > 128) {
|
|
die(json_encode([
|
|
'status' => 'error',
|
|
'message' => 'device 不能超过 128 个字符'
|
|
], JSON_UNESCAPED_UNICODE));
|
|
}
|
|
|
|
// get from redis
|
|
$data = $redis->get(md5($device));
|
|
|
|
if (empty($data)) {
|
|
echo json_encode([
|
|
'status' => 'empty',
|
|
'message' => $msg
|
|
], JSON_UNESCAPED_UNICODE);
|
|
} else {
|
|
echo $data;
|
|
$redis->del(md5($device));
|
|
}
|
|
|
|
// delete from redis
|