首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >代码点火器:使用RESTful服务

代码点火器:使用RESTful服务
EN

Stack Overflow用户
提问于 2013-08-08 00:06:43
回答 2查看 8.8K关注 0票数 3

是否有一个易于设置的代码点火器REST库,我可以使用它来使用RESTful服务?我试着设置库。但不能设置Spark。尝试了以下步骤:

  1. 在codeigniter目录的根目录中添加一个名为sparks的目录。
  2. 向application/core/MY_Loader.php添加自定义Loader类。

它给了我另一个错误,Cannot find spark path at sparks/curl/1.2.1/。现在我被困住了。不知道为什么在代码点火器中设置RESTful API如此困难。

更新:当我尝试运行时

代码语言:javascript
复制
$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()

EN

回答 2

Stack Overflow用户

发布于 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行开始

代码语言:javascript
复制
/* 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库,并注释出火花引用。

代码语言:javascript
复制
        $this->_ci->load->library('curl');


    // Load the cURL spark which this is dependant on
    // $this->_ci->load->spark('curl/1.2.1');
票数 2
EN

Stack Overflow用户

发布于 2015-08-14 08:19:43

您可以通过在应用程序根目录(不是应用程序文件夹)上运行以下命令来安装curl 1.2.1:

代码语言:javascript
复制
php tools/spark install -v1.2.1 curl

来源

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18115849

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档