php - How can I display my tweet feed with Rest Client and Codeigniter? -


i have got tweet feed displaying... completly out of format. point me in right direction finishing touches? have created tweet model, results printing in controller. @ minute printing in json file.. below model code...

<?php 

class tweet_model extends ci_model {

public function __construct() {     $this->load->database(); }  public function get_tweet() {     // load rest client spark     $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');     return $tweets; } 

}

and below controller code...

 $mytweets = $this->tweet_model->get_tweet();      print_r($mytweets); 

but displays every last bit of information in json file following link...

https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=jenksuy&count=2

how fix show formatted tweets?

first of all, parse json data this

$tweetobjects = json_decode($tweets) 

now if want display each message, you'll have this:

foreach ($tweetobjects['results'] $tweet) { echo $tweet['text']; } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -