我试图用$this->post()json格式发送邮件发送的数据.我无法得到任何结果$this->post('name').
这是代码:
<?php
require(APPPATH . '/libraries/REST_Controller.php');
class user_api extends REST_Controller {
function user_post() {
$user = array(
'id' => null,
'firstname' => $this->post('firstname'),
'lastname' => $this->post('lastname')
);
$result = $this->user_model->insert($user);
if ($result) {
$this->response($result, 200); // 200 being the HTTP response code
} else {
$this->response(NULL, 404);
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
以json格式发送到链接的数据:http://mydomain.com/myapplication/user_api/user:
{"firstname":"test",
"lastname":"test"
}
Run Code Online (Sandbox Code Playgroud)
数据库中没有数据,因为它无法从中获取数据$this->post('firstname').
任何的想法 ????