0

我是 codeigniter 的新手,我正在使用 Phil Sturgeon 的 REST 服务器来提供“发布”类型的 Web 服务。尽管我的“get”类型的 Web 服务运行良好。下面是我的后期网络服务控制器代码。

要求(APPPATH.'库/REST_Controller.php');

类 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 检查 Web 服务是否正常工作,但我遇到了错误。

致命错误:未捕获的异常“异常”,消息“格式类不支持从“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):

http://awesomescreenshot.com/0cd38frz01 是rest插件错误的截图

如果我的代码中还有任何内容,请让我知道我还需要做什么,并请让我知道使用 REST 服务器进行“发布”Web 服务的整个过程。提前致谢

4

1 回答 1

0

在 RESTClient 的正文中,尝试发送:

id=restClient%20Test

代替

{"id": "restCliente Test"}
于 2014-07-30T14:58:34.300 回答