首页 文章

Codeigniter restclient无法正常工作

提问于
浏览
5

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

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

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

  • 复制Rest.php文件(从GitHub下载)并将其放在libraries文件夹中

  • 下载Curl library并将其放入库中

  • 修改了Rest.php中的代码以取消注释 $this->_ci->load->library('curl'); (如果我将鼠标悬停在此文件中的curl库的用法上,我会得到以下消息):

CI_Controller中找不到字段'curl'

  • 我创建了一个名为“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);
}

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

D:\wamp\www\codeigniter\application\controllers\api\Restclient.php:36:null

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

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

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

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

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

1 回答

  • 1

    我知道你的问题是针对这里提到的图书馆的 . 你还试过别的吗?我用guzzle http取得了很好的成功

    https://github.com/guzzle/guzzle

相关问题