我正在編寫一個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