$manufactureNo,
'device_id' => $device_id,
'project' => $projectNo,
'model' => $modelNo,
'production' => $productionNo,
'timestamp' => $timestamp,
'sign' => $sign,
];
$params = json_encode($params);
//$params = '{"manufacture":"0002","device_id":"6705BF36C37F","project":"0002","model":"0003","production":"0002","timestamp":"1500000000","sign":"2b67361ba972020496f1a1b3df388499"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionUpgrade()
{
$url = 'http://kingb:8012/app-api/web/reportDeviceVersion';
$params = [
'barcode' => '00001',
'device_id' => 'DEVICE001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.2',
'timestamp' => 1500000000
];
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionAec()
{
$aes = new Aes('12345678');
$encrypted = $aes->encrypt('this is en AES testing');
echo '要加密的字符串:this is en AES testing
加密后的字符串:'. $encrypted. '
';
$decrypted = $aes->decrypt($encrypted);
echo '要解密的字符串:'. $encrypted, '
解密后的字符串:'. $decrypted;
}
public function actionDeviceSt()
{
$url = 'http://kingb:8012/app-api/web/reportDeviceVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DEVICE003',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.2',
'timestamp' => 1500000000
];
$postResult = Http::POST($url, json_encode($params));
echo $postResult;
}
public function actionCheckAppUpdate()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/checkAppVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DEVICE000001',
'current_version' => 'V1.0.1',
'package_name' => 'V1.0.2安装包',
];
//$params = json_decode($params);
$params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","package_name":"com.kingboard.settings","current_version":"1"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionCheckOtaUpdate()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/checkOtaVersion';
//$url = 'http://kingb:8012/app-api/web/checkOtaVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.1',
];
$params = json_encode($params);
$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","software_version":"V1.00.1A.20191002","hardware_version":""}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
//{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022","target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}
public function actionReportOtaEvent()
{
//actionCheckAppVersion
$url = 'http://47.107.95.101/app-api/web/reportOtaUpgradeEvent';
//$url = 'http://kingb:8012/app-api/web/reportOtaUpgradeEvent';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'software_version' => 'V1.0.1',
'hardware_version' => 'V1.0.1',
];
$params = json_encode($params);
$params = '{"barcode":"0001000100010001","device_id":"DEVICEID00001","current_version":"V1.00.1A.20191022", "target_version":"V1.00.1A.20191022","status":5,"timestamp":"1572759793"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionReportAppEvent()
{
//actionCheckAppVersion
//$url = 'http://47.107.95.101/app-api/web/reportAppUpgradeEvent';
$url = 'http://kingb:8012/app-api/web/reportAppUpgradeEvent';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DGDEVBICEID00001',
'current_version' => 'V1.0.1',
'target_version' => 'V1.0.1',
'package_name' => 'com.app.king.dd',
"status" => 0,
"error_code" => '',
"timestamp" => 1572767677
];
$params = json_encode($params);
//$params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","current_version":"1","target_version":"2","status":"5","error_code":"0","timestamp":"1572767677"}';
$postResult = Http::POST($url, $params);
echo $postResult;
}
public function actionEncodePost()
{
$url = 'http://kingb:8012/app-api/web/CryptTxt';
$randKey = '98765432';//Utils::rand(32);
$rsa = new RSACrypt();
$aes = new Aes($randKey);
$deviceId = 'oelooeloeloeloe';
$manufactureNo = '0001';
$tt = time();
$sign = md5($deviceId . $tt . $randKey);
$dd = json_encode(['manufacture' => $manufactureNo, 'timestamp' => $tt, 'sign' => $sign, 'device_id' => $deviceId]);
$params = [
'randomKey' => $rsa->encrypt($randKey),
'content' => $aes->encrypt($dd)
];
$params = json_encode($params);
$postResult = Http::POST($url, $params);
$postResult = json_decode($postResult, true);
$decodeJson = $aes->decrypt($postResult['content']);
print_r($decodeJson);
}
/**
*
*/
public function actionAuthDeviceT()
{
$url = 'http://kingb:8012/app-api/web/authDeviceT';
//$url = 'http://47.107.95.101/app-api/web/authDeviceT';
$manufactureNo = '0001';
$device_id = 'DEVICE00000A';
$projectNo = '0001';
$modelNo = '0001';
$productionNo = '0001';
$timestamp = time();
$randKey = Utils::rand(16).$timestamp;
$salt = "13456";
$sign = md5($manufactureNo. $projectNo. $modelNo . $productionNo . $timestamp .$device_id. $salt);
$deviceParams = [
'manufacture' => $manufactureNo,
'device_id' => $device_id,
'project' => $projectNo,
'model' => $modelNo,
'production' => $productionNo,
'timestamp' => $timestamp,
'sign' => $sign,
];
$deviceParams = json_encode($deviceParams);
$rsa = new RSACrypt();
$randomKey = $rsa->encrypt($randKey);
$aes = new Aes($randKey);
$params = [
'randomKey' => $randomKey,
'content' => $aes->encrypt($deviceParams)
];
$params = json_encode($params);
$postResult = Http::POST($url, $params);
$postResult = json_decode($postResult, true);
$decodeJson = $aes->decrypt($postResult['content']);
echo $decodeJson;
}
public function actionA()
{
$str = "87654321";
$rsa = new RSACrypt();
$deStr = "i5fNIUnPIFuSWeSIfh6f2Ehrm101XQMKRKuJ86QdrswO90jzcTw6LxWZDDe9YaS6KEnnUP8QaKuFKNEZlY+UsLWxBSKLwPEt3Qf7TAV6bXQBIYBzOXZTFpjvaBa+v1nQFrBPhYBo\/2RF5uVhk8xEilIe7A2XQLEvvhowIjFJevE=";
//echo $deStr."\r\n";
echo $rsa->decrypt($deStr);
}
}