OpenMicroBlogger.org

OpenMicroBlogger icon


Implementing the public_timeline.json Twitter API method

Now that we can post statuses via Twitter API (see previous post), here is a quick how to on the next item in our Twitter API to-do-list:

image

// get some variables in scope
extract( $vars );
$tweets = array();

$callback = $_GET['callback'];

// get the data model for the "posts" table
$Post = $db->model( 'Post' );

// search for the most recent 10 records
$Post->find();

// loop over each record
while ( $p = $Post->MoveNext() ) {

  $profile = owner_of( $p );

  $tweet = array();

  $user = array(
     'screen_name' => $profile->nickname
  );

  $tweet['text'] = $p->title;
  $tweet['truncated'] = 'false';
  $tweet['created_at'] = date( "D M d G:i:s O Y", strtotime( $p->created ));
  $tweet['in_reply_to_status_id'] = null;
  $tweet['source'] = null;
  $tweet['id'] = intval( $p->id );
  $tweet['favorited'] ='false';
  $tweet['user'] = $user;

  $tweets[] = $tweet;

}

echo $callback."(";

// load the JSON class
$json = new Services_JSON();

// create the JSON data
echo $json->encode( $tweets );

echo ");";

Wed Apr 8 10:53 PM










Sign In to post comments







Bookmark this:

Bookmark to Blinklist! Bookmark to Blogmarks! Bookmark to Del.icio.us! Bookmark to De.lirio.us! Bookmark to Digg! Bookmark to Fark! Bookmark to Furl! Bookmark to Ma.gnolia! Bookmark to Newsvine! Bookmark to Reddit! Bookmark to Scuttle! Bookmark to Simpy! Bookmark to Spurl! Bookmark to StumbleUpon! Bookmark to Technorati! Bookmark to Yahoo! My Web!






Support This Project

Keep tabs on this project by following Brian on Twitter: