我正在编写一个Web服务来验证用户登录是否有效。下面是放置在UsersController.php中的Web服务的简单实现:Web服务登录以检查在cakephp中验证用户
public function webservice_login()
{
$this->autoRender = false;
if ($this->request->is('post'))
{
if ($this->Auth->login())
{
echo json_encode(array('ok_msg' => 'User authentication success'));
}
else
{
echo json_encode(array('fail_msg' => 'User authentication failure'));
}
}
}
它不起作用。我收到的错误信息是这样的;
\n\tError: \n\tPostsController could not be found.
\n
\n\tError: \n\tCreate the class PostsController below in file: app\\Controller\\PostsController.php
\n
\n<?php\nclass PostsController extends AppController {\n\n}\n
\n
\n\tNotice: \n\tIf you want to customize this error message, create app\\View\\Errors\\missing_controller.ctp
代码有什么问题?我应该如何重写Web服务?我正在使用Cakephp 2.5。奇怪的是,我没有一个名为Post的控制器。
你可以发送请求的网址,你收到错误? – engvrdr 2014-10-09 11:10:22
你没有控制器的帖子?那么你的控制者是什么?您是否使用过$ this-> Auth-> allow()作为webservice_login存在的函数 – Abhishek 2014-10-09 11:52:14
显示您要调用的URL。 – burzum 2014-10-09 12:32:26