php - Codeigniter: Consume RESTful service -
is there easy setup codeigniter rest library can use consume restful service? tried setting this library. not set spark
. tried following steps:
- adding directory named sparks in root of codeigniter directory
- adding custom loader class application/core/my_loader.php.
it gave me error cannot find spark path @ sparks/curl/1.2.1/
. stuck. wondering why hard setup restful api in codeigniter.
update: when try run
$this->load->spark('restclient/2.1.0'); // load library $this->load->library('rest'); // run setup $this->rest->initialize(array('server' => 'http://api.twitter.com/')); // pull in 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'] $tweet) { log_message('info', $tweet['text']); }
i getting error: call undefined method ci_loader::spark()
sparks not necessary see edit. use tutorial start, author wrote libraries
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/
download these 2 work tutorial:
https://github.com/philsturgeon/codeigniter-restserver
https://github.com/philsturgeon/codeigniter-restclient
also @ end of tutorial - theres many comments , questions, , tutorial author has answered many of them
edit - whoops forgot have change 1 line. , need dl ci curl library. ok in rest client, in file rest.php starting @ line 53
/* not using sparks? bloody should be. | if going stick in mud old fashioned way $this->_ci->load->library('curl'); */ // load curl spark dependant on $this->_ci->load->spark('curl/1.2.1');
so change load curl library traditional way , commment out spark reference
$this->_ci->load->library('curl'); // load curl spark dependant on // $this->_ci->load->spark('curl/1.2.1');
Comments
Post a Comment