thinkphp에서 API 인터페이스 클라이언트 및 서버의 시간 일관성 솔루션 알아보기
배경
클라이언트 (앱, 애플릿)와 서버의 시간이 일치하지 않습니다.
해결책
1. 새 시간 컨트롤러 만들기
<?php
namespace app\api\controller;
use think\Controller;
class Time extends Controller
{
public function index()
{
$data = array(
'time' => time(),
);
return show(0, '', $data);
}
}
2. 경로 수정
//get方式
Route::get('time', 'api/time/index');