TestController.php
2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace console\controllers;
/**
* Created by PhpStorm.
* User: scott
* Date: 8/15/18
* Time: 11:32 AM
*/
use app\api\helpers\Aes;
use common\exts\Http;
use domain\device\Device;
use GuzzleHttp\Psr7;
use yii\console\Controller;
use GuzzleHttp\Psr7\Request;
use function chr;
use yii\helpers\ArrayHelper;
class TestController extends Controller
{
public function actionGen()
{
echo sprintf('%04x', 1);
}
public function actionDeviceAuth()
{
$url = 'http://kingb:8012/app-api/web/authDevice';
$manufactureNo = '0002';
$device_id = 'SZDEVICE000037';
$projectNo = '002';
$modelNo = '002';
$productionNo = '0001';
$timestamp = time();
$salt = 13456;
$sign = md5($manufactureNo. $projectNo. $modelNo . $productionNo . $timestamp . $salt);
$params = [
'manufacture' => $manufactureNo,
'device_id' => $device_id,
'project' => $projectNo,
'model' => $modelNo,
'production' => $productionNo,
'timestamp' => $timestamp,
'sign' => $sign,
];
$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<br>加密后的字符串:'. $encrypted. '<hr>';
$decrypted = $aes->decrypt($encrypted);
echo '要解密的字符串:'. $encrypted, '<br>解密后的字符串:'. $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://kingb:8012/app-api/web/checkAppVersion';
$params = [
'barcode' => '0001000100010001',
'device_id' => 'DEVICE000001',
'current_version' => 'V1.0.1',
'package_name' => 'com.ota.app.pro',
];
$postResult = Http::POST($url, json_encode($params));
echo $postResult;
}
}