是否有一个易于设置的代码点火器REST库,我可以使用它来使用RESTful服务?我试着设置这库。但不能设置Spark。尝试了以下步骤:
它给了我另一个错误,Cannot find spark path at sparks/curl/1.2.1/。现在我被困住了。不知道为什么在代码点火器中设置RESTful API如此困难。
更新:当我尝试运行时
$this->load->spark('restclient/2.1.0');
// Load the library
$this->load->library('rest');
// Run some setup
$this->rest->initialize(array('server' => 'http://api.twitter.com/'));
// Pull in an array of tweets
$tweets = $this->rest->get('1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=jenksuy&count=2');
$tweetobjects = json_decode($tweets);
foreach ($tweetobjects['results'] as $tweet) {
log_message('info', $tweet['text']);
}我要去找Error: Call to undefined method CI_Loader::spark()
发布于 2013-08-08 00:57:14
火花是不必要的,请参阅编辑。使用本教程开始,作者还编写了库。
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
请下载这两篇教程,以便使用本教程:
https://github.com/philsturgeon/codeigniter-restserver
https://github.com/philsturgeon/codeigniter-restclient
在本教程的末尾,还有许多评论和问题,教程作者已经回答了其中的许多问题。
编辑-喔,忘了你必须换一行。你将需要DL的CI卷曲库。好的,在rest客户机中,在文件Rest.php中,从第53行开始
/* Not using Sparks? You bloody well should be.
| If you are going to be a stick in the mud then do it the old fashioned way
$this->_ci->load->library('curl');
*/
// Load the cURL spark which this is dependant on
$this->_ci->load->spark('curl/1.2.1');因此,将其更改为按传统方式加载curl库,并注释出火花引用。
$this->_ci->load->library('curl');
// Load the cURL spark which this is dependant on
// $this->_ci->load->spark('curl/1.2.1');发布于 2015-08-14 08:19:43
您可以通过在应用程序根目录(不是应用程序文件夹)上运行以下命令来安装curl 1.2.1:
php tools/spark install -v1.2.1 curl来源
https://stackoverflow.com/questions/18115849
复制相似问题