面临的错误问题:
1. APP强退(反映强退的情况)
2. 数据加载失败
3. APP潜在问题
*错误信息接口:/var/www/app/error.php*
```
require_once('./common.php');
class ErrorLog extends Common {
public function index() {
$this->check();
// 查看是否存在错误信息
$errorLog = isset($_POST['error_log']) ? $_POST['error_log'] : '';
if (!$errorLog) {
return Response::show(401, '日志为空');
}
$sql = "insert into error_log(`app_id`, `did`, `version_id`, `version_mini`, `error_log`, `create_time`)
values(
" . $this->params['app_id'] . ",
'" . $this->params['did'] . "',
" . $this->params['version_id'] . ",
" . $this->params['version_mini'] . ",
'" . $errorLog . "',
" . time() . "
)";
// 插入错误信息
$connect = Db::getInstance()->connect();
if(mysql_query($sql, $connect)) {
return Response::show(200, '错误信息插入成功');
} else {
return Response::show(400, '错误信息插入失败');
}
}
}
$error = new ErrorLog();
$error->index();
```
*错误信息模拟POST页面:/var/www/app/init.html*
```
<form action="http://192.168.2.110/app/error.php?format=xml" method="post" accept-charset="utf-8">
设备号:<input type="text" value="" name="did" /> <br />
版本号:<input type="text" value="" name="version_id" /> <br />
小版本号:<input type="text" value="" name="version_mini" /> <br />
APP类型:<input type="text" value="" name="app_id" /> <br />
error_log:<input type="text" name="error_log"> <br />
encrypt_did:<input type="text" value="c39f07bf54425745d642498395ce144c" name="encrypt_did" /> <br />
<input type="submit" value="提交">
</form>
```