我读过以下主题/教程:Codeigniter RESTful API服务器 - XML错误?
- Codeigniter RESTful API Server
- http://code.tutsplus.com/tutorials/working-with-restful-services-in-codeigniter--net-8814
- https://github.com/chriskacerguis/codeigniter-restserver
我仍然想不通为什么我的路线问题和XML很问题。 我的web控制器是文件夹controllers/api/webservice.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH.'/libraries/RESTful/REST_Controller.php';
class webservice extends REST_Controller{
function get() {
$data = array();
$data['name'] = "TESTNAME";
$this->response($data);
}
}
在教程没有必要添加路由,并且为了获得我需要添加以下路由XML页面错误或它不会工作:
$route['api/webservice/get'] = 'api/webservice/get';
我笨的结构文件夹:
> application
> config
rest.php (did not change anything from the GitHub download)
> controllers
> api
webservice.php
key.php
> libraries
> RESTful
REST_Controller.php (changed line 206 to: $this->load->library('RESTful/format');)
format.php
从教程,下面的链接作品,未经路线:
http://localhost/testRestful/index.php/api/example/users
矿仅适用于路线
http://localhost/myproject/index.php/api/webservice/get
我收到以下错误: 它没有说别的。我无法弄清楚哪个文件是错误的。
是你的完整控制器代码吗? – Craig 2014-12-05 12:43:10
@克雷格是的。我只是测试,所以我的控制器中没有其他东西。 – Linesofcode 2014-12-05 13:59:41
我只问,因为我确信我们之前有过这个问题,这是通过删除不需要的空白区域来解决的。 – Craig 2014-12-05 14:11:08