在Codeigniter 2.0中使用rest api时,总是出现“ status”:false

时间:2018-08-01 07:18:14

标签: php codeigniter-2 codeigniter-restserver codeigniter-restapi

我在项目中使用Ashimante Rest Server API

这就是我所做的:-

  1. 我已将Rest.php控制器放在应用程序/库中 文件夹
  2. 我已经在以下位置创建了 webservice-v1 文件夹 application / controllers / 文件夹,即 application / controllers / webservice-v1
  3. 我有控制器文件 rest_api_common.php webservice_test.php 放在webservice-v1文件夹中。

这是我的rest_api_common.php代码:-

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH . 'libraries/Rest.php');
class Rest_api_common extends REST {

    // some variable declarations //

    public function __construct() {
        parent::__construct();
        // loading models and custom config files// 
    }
}

我希望所有Web服务功能都可以使用变量和功能。所以我的webservice_test.php文件代码如下:-

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
include('rest_api_common.php');
class Webservice_test extends Rest_api_common
{
    function  __construct(){
        parent::__construct();
    }

    public function mongodata_post()
    {
        $this->response(array(),200);
    }
}

我已经定义了这样的路线:-

$route['rest-api/v1/mongodata'] = "webservice-v1/webservice_test/mongodata_post";

使用邮递员应用程序,我正在使用POST方法调用这样的API:-

http://testdomain.com/rest-api/v1/mongodata

我收到此回复:-

{"status":false,"error":false}

我在做什么错了?

0 个答案:

没有答案