}
        } else {
            $app->sfunc->forbidden403($app);
        }
    } catch (\Exception $e) {
        $app->oauth->catcher($e);
    }
});
$app->post('/resource/chat/{uuid:[0-9]+}/{targetid:[0-9]+}', function ($uuid, $targetid) use($app) {
    $inputs = $app->sfunc->getContentTypeFromPost();
    try {
        // Check that an access token is present and is valid
        $app->oauth->resource->isValidRequest();
        //get and check the user id by AccessToken
        $app->sfunc->isValidUUID($app, $uuid);
        $chatLog = new ChatLogs();
        $chatLog->originid = $uuid;
        $chatLog->origintype = isset($inputs['ot']) ? $inputs['ot'] : "0";
        $chatLog->targetid = $targetid;
        $chatLog->targettype = isset($inputs['tt']) ? $inputs['tt'] : "0";
        if (isset($inputs['co'])) {
            $chatLog->content = $inputs['co'];
        }
        if (isset($inputs['json'])) {
            $chatLog->json = $inputs['json'];
        }
        $chatLog->save();
        $app->sfunc->jsonOutput($app, array('status' => 200, 'logid' => $chatLog->id));
    } catch (\Exception $e) {
        var_dump($e);
        $app->oauth->catcher($e);
<?php

$app->get('/', function () use($app) {
    $app->response->setContentType('application/json', 'UTF-8');
    /*
    if(!$app->oauthredis->exists(':AuthCode:51'))
    	$app->oauthredis->save(':AuthCode:51', 'gsdfdsasdsdfewrewfddsfsd');
    
    $data = $app->oauthredis->get(':AuthCode:51');
    */
    $apiserverTime = date("Y-m-d H:i:s");
    $modelAtNiuServer = new NiuUsrInfo();
    $modelAtOauthServer = new ChatLogs();
    echo json_encode(array('status' => 200, 'NiuServer' => NiuUsrInfo::findFirst()->id, 'OauthServer' => ChatLogs::findFirst()->id, 'message' => 'welcome!歡迎!', 'apiserverTime' => $apiserverTime, 'dbServerTime' => $modelAtNiuServer->getServerTime(), 'authServerTime' => $modelAtOauthServer->getServerTime()), JSON_UNESCAPED_UNICODE);
});
/*
//stay for debug purpose
$app->get('/backdoor/{uuid:[0-9]+}', function($uuid) use($app) {
	
	$user = NiuUsrInfo::findFirst("id = $uuid");
	if(!$user)
		$app->sfunc->forbidden403($app);
	try 
	{
		$app->totp->setSecret($user->gasecret); 
		$totp = $app->totp->calculate(); // stay for debug
		echo ($totp);
	} catch (\Exception $e) {
		var_dump($e);
        $app->oauth->catcher($e);
    }