【发布时间】:2014-09-22 02:32:54
【问题描述】:
我是 codeigniter 的新手,我正在使用 Phil Sturgeon 的 REST 服务器来提供“发布”类型的 Web 服务。尽管我的“get”类型的 Web 服务运行良好。下面是我用于发布网络服务的控制器代码。
require(APPPATH.'libraries/REST_Controller.php');
class json 扩展 REST_Controller {
public function __construct() {
parent::__construct();
}
public function data_post() {
$user = array(
'id' => $params['id']
);
$this->response(array('status'=>'success'), 200);
}
}
我正在使用 rest add on 检查网络服务是否正常工作,但我遇到了错误。
致命错误:未捕获的异常 'Exception' 带有消息“格式类不支持从“php”转换。'在 /home/magnetic/public_html/touch/order-form/application/libraries/Format.php:51 堆栈跟踪:#0 /home/magnetic/public_html/touch/order-form/application/libraries/Format.php(31 ): Format->__construct('{"id": "restCli...', 'php') #1 /home/magnetic/public_html/touch/order-form/application/libraries/REST_Controller.php(247): Format->factory('{"id": "restCli...', 'php') #2 /home/magnetic/public_html/touch/order-form/application/controllers/json.php(6): REST_Controller- >__construct() #3 /home/magnetic/public_html/touch/order-form/system/core/CodeIgniter.php(308): json->__construct() #4 /home/magnetic/public_html/touch/order-form /index.php(202): require_once('/home/magnetic/...') #5 {main} 在 /home/magnetic/public_html/touch/order-form/application/libraries/Format.php 上线51
http://awesomescreenshot.com/0cd38frz01 是rest插件错误截图
如果我的代码中还有任何内容,请让我知道我还需要做什么,并请让我知道使用 REST 服务器进行“发布”Web 服务的整个过程。 提前致谢
【问题讨论】:
标签: php json web-services codeigniter codeigniter-restserver