From 990101b269069e0a5dd6a677440dd8eac079e2f6 Mon Sep 17 00:00:00 2001 From: yang Date: Thu, 2 Apr 2015 12:32:44 +0800 Subject: [PATCH] =?UTF-8?q?Log=E6=96=B0=E5=A2=9E=E7=B4=80=E9=8C=84api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/api/v2/index.php | 56 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/htdocs/api/v2/index.php b/htdocs/api/v2/index.php index 1a8dbc0..1d3bc44 100644 --- a/htdocs/api/v2/index.php +++ b/htdocs/api/v2/index.php @@ -49,18 +49,19 @@ $app->get('/hello/:name', 'APIrequest', function ($name) use ($app) { function login($user_id = null) { $app = \Slim\Slim::getInstance(); - if(!isset($user_id)) { - $user_id = $_POST['user_id']; - } // 取得帶來的參數 $cType = $app->request->getContentType(); if($cType == 'application/x-www-form-urlencoded') { + if(!isset($user_id)) { + $user_id = $_POST['user_id']; + } $password = $_POST['password']; $browser = isset($_POST['browser']) ? $_POST['browser'] : 'api'; } else /*if($cType == 'application/json')*/ { $postData = $app->request->getBody(); $postDataArray = json_decode($postData); + $user_id = $postDataArray->user_id; $password = $postDataArray->password; $browser = isset($postDataArray->browser) ? $postDataArray->browser : 'api'; @@ -1459,7 +1460,54 @@ $app->group('/tokens', 'APIrequest', function () use ($app, $app_template) { // ============================================================================ /* - * 推薦學習點 + * 輸入所有紀錄 + * GET http://localhost/api/v2/logs + */ +$app->post('/logs', /*'APIrequest',*/ function () use ($app) { + $app = \Slim\Slim::getInstance(); + + // 取得帶來的參數 + $cType = $app->request->getContentType(); + + if($cType == 'application/json') { + $postData = $app->request->getBody(); + $postDataJson = json_decode($postData); + + $logs_json = $postDataJson->logs_data; + } + + for($i=0; $iLID; + $uid = $logs_json[$i]->UID; + $date = $logs_json[$i]->Date; + if(isset($logs_json[$i]->SaID)) { + $said = $logs_json[$i]->SaID; + } + $actiongroup = $logs_json[$i]->ActionGroup; + $encode = $logs_json[$i]->Encode; + if(isset($logs_json[$i]->TID)) { + $tid = $logs_json[$i]->TID; + } + if(isset($logs_json[$i]->QID)) { + $qid = $logs_json[$i]->QID; + } + if(isset($logs_json[$i]->Answer)) { + $answer = $logs_json[$i]->Answer; + } + if(isset($logs_json[$i]->Other)) { + $other = $logs_json[$i]->Other; + } + } + + $app->render(201,array( + 'error' => false + )); +}); + +// ============================================================================ + +/* + * 取得館場資訊 * GET http://localhost/api/v2/info */ $app->get('/info', 'APIrequest', function () use ($app) {