|
|
@@ -0,0 +1,33 @@
|
|
|
+<?php
|
|
|
+defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
+
|
|
|
+class User extends CI_Controller
|
|
|
+{
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ parent::__construct();
|
|
|
+ $this->output->set_content_type('application/json');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 访问:GET /api/v1/user/center
|
|
|
+ public function center()
|
|
|
+ {
|
|
|
+ $data = [
|
|
|
+ 'code' => 200,
|
|
|
+ 'version' => 'v1',
|
|
|
+ 'data' => [
|
|
|
+ 'username' => 'John Doe',
|
|
|
+ 'email' => 'john@example.com'
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $this->output->set_output(json_encode($data));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 访问:POST /api/v1/user/login
|
|
|
+ public function login()
|
|
|
+ {
|
|
|
+ // 从输入流获取JSON数据
|
|
|
+ $input = json_decode(file_get_contents('php://input'), true);
|
|
|
+ // 业务逻辑...
|
|
|
+ }
|
|
|
+}
|