我是CodeIgniter和Rest API的新手。我试图在CodeIgniter中实现REST API,并使用了Phil Sturgeon的rest-client和rest-server。我看了几个教程,并成功实施了Rest-Server部分(使用Chrome的Rest Client APP进行检查)。但是,为了实施Rest-Client,我遇到了一些麻烦。如何使用codeigniter中的rest_client调用
我需要有卷曲和CodeIgniter的curl库? 如果是,我应该如何设置它?
I watched this tutorial too by Phil Sturgeon但在本教程中,他只用了REST的客户端函数来调用服务器。但没有定义放在哪里。这里的代码
function rest_client($id){
$this->load->library('rest', array(
'server' => 'http://localhost/rest/index.php/restgetcontroller/',
));
$user = $this->rest->get('user', array('id' => $id), 'json');
echo $user->name;
}
如果太简单,我很抱歉。
谢谢
编辑:我做了一个客户控制器,并把有一个方法来调用它。但是当我加载页面时,我得到这个错误。
Call to undefined method CI_Loader::spark()