I added a Twitter class to the CMS, which will pull your tweets into the system for display. The first time the class is called, it will pull (up to / the last) 200 tweets from the "user_timeline.xml" feed that Twitter generates from your account, and store them in the database. It also records a "twitter_last_updated" time stamp, which it uses to determine whether it's time to check for new tweets. By default it waits 7 minutes, in an effort to keep the API count down.
Here is a barebones call:
$twitter = new twitter;
$twitter->account_username = "username";
$twitter->account_password = "password";
$twitter->show_timeline(3);
The account_username and account_password methods are used to set the credentials for the class, and the show_timeline() method is the final call that generates the list of tweets. Adding a number to that method ( show_timeline(X) ) will show X number of tweets, and will show 5 tweets by default.
An exciting method of customization exists for the twitter class! Using the layout() method, we can pass along some HTML which will determine the code that gets generated for each tweet.
$display = '<div class="padding10 text_bg_gradient_only all_lines">$description</div><br />';
$twitter = new twitter;
$twitter->layout($display);
$twitter->show_timeline(3);
We have set $display to be a <div> with some stacked styles, containing the $description variable. Note: If we wrap the HTML in the single quote, we don't have to worry about escaping the double quotes. Once we have our layout determined, we can pass it to the class using "layout($display)". Just for comparison, here is the default display:
<div class="padding5"><a href="http://www.twitter.com/$screen_name" target="_blank"><img src="$profile_image_url" title="$user_name" class="floatL clearR padding2" /></a><div>$name</div><div>$description<div>From $source</div></div></div>
By default, the time stamp display is turned off. With the show_timestamp() method, it will display something like this:
If we add some formatting to the show_timestamp() method, we can tell it how to display. This uses PHP's date() function, so you can find all the formatting options here. Using the code below--
$twitter = new twitter;
$twitter->show_timestamp("m/d/Y @ g:ia");
$twitter->show_timeline(1);
--will produce an output like this:
Update!
I just realized that I forgot to post the variables details for use with the layout() method. Here they are:
$screen_name - twitter account name, i.e., "lightningbox"
$profile_image_url - the URL for the avatar; use as '<img src="$profile_image_url" />'
$user_name - my profile's full name, i.e., "Brian A. Boyce"
$location - my profile's home location, i.e., "Sterling Heights, MI"
$url - my profile's website URL
$description - the body of the tweet itself
$source - where I'm tweeting from, i.e., "web", "tweetdeck", "tiny twitter", etc