Codeigniter restclient无法正常工作

Den*_*nis 5 php rest curl codeigniter

我正在尝试为我的解决方案安装CodeIgniter RESTClient和RESTServer库.(philsturgeon-codeigniter-restclientchriskacerguis-codeigniter-restserver).

我设法让其他服务器启动并运行,但我遇到了其他客户端的问题.

这些是我现在所做的步骤:

  1. 复制Rest.php文件(从GitHub下载)并将其放在libraries文件夹中
  2. 下载Curl库并将其放入库中
  3. 修改了Rest.php中的代码以取消注释$this->_ci->load->library('curl');(如果我将鼠标悬停在此文件中的curl库的用法上,则会收到以下消息):

在CI_Controller中找不到字段'curl'

  1. 我创建了一个名为"Restclient"的新控制器来测试我的API.在这个控制器中,我创建了以下方法:

    function rest_client_example($id)
    {
        $this->load->library('rest', array(
            'server' => 'localhost/codeigniter/api/users/'
        ));
    
        $user = $this->rest->get('volunteer', array('id' => $id), 'json');
    
        var_dump($user);
    }
    
    Run Code Online (Sandbox Code Playgroud)

浏览到http:// localhost/codeigniter/api/restclient/rest_client_example/25然后给我

D:\wamp\www\codeigniter\application\controllers\api\Restclient.php:36:null
Run Code Online (Sandbox Code Playgroud)

执行以下代码而不是上面的代码时,我得到了正确的结果:

    $this->load->library('curl');

    $t = $this->curl->simple_get('api/users/volunteer', array('id'=>$id));
    var_dump($t);
Run Code Online (Sandbox Code Playgroud)

所以我知道卷曲是有效的.

我的猜测是我在加载curl库时遇到了什么问题?

Jay*_*Tee 1

我知道您的问题是针对此处提到的图书馆的。你还尝试过其他什么吗?我在 guzzle http 方面取得了非常好的成功

https://github.com/guzzle/guzzle