This commit is contained in:
2017-10-24 06:35:34 +08:00
parent a74cef459c
commit 4957f3770b
6 changed files with 131 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ class Api {
public function __construct() {
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
$header = getallheaders();
$this->data = array('code' => 0, 'msg' => '', 'time' => time(), 'data' => '');
@@ -24,12 +24,12 @@ class Api {
if (!$isCheck && 'api/index/gettoken' !== strtolower($url)) {
$this->data['code'] = '301';
$this->data['data'] = '非法请求!';
echo json($this->data);
echo json_encode($this->data);
exit();
}
}
protected function checkToken($header){return true;
protected function checkToken($header){
if (isset($header['Authorization']) && $header['Authorization']) {
$token = authcode($header['Authorization']);
list($appid, $appsecret, $currentTime) = explode('|', $token);