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:
// 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:
|
|
|
|
|















