[PHP開發APP接口]①⑤--錯誤日志接口

Paste_Image.png
Paste_Image.png

error_log.php

<?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(401, '錯誤信息插入失敗');
        }
    }
}

$error = new ErrorLog();
$error->index();

test.html

<html>
<form action="http://127.0.0.1/testapp/init.php" method="post">
    設備號:<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/>
    encrypt_did:<input type="text" value="c39f07bf54425745d642498395ce144c" name="encrypt_did"/><br/>
    <input type="submit" value="提交"/>
</form>

<form action="http://127.0.0.1/testapp/error.php" method="post">
    設備號:<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/>
    errorLog:<input type="text" value="" name="error_log"/><br/>
    encrypt_did:<input type="text" value="c39f07bf54425745d642498395ce144c" name="encrypt_did"/><br/>
    <input type="submit" value="提交"/>
</form>
</html>
Paste_Image.png
Paste_Image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容