WordPress Tools: MW Latest Tweet


When you unzip the archive, you'll find the plugin file mw_latest_tweet.php and a directory called mw_latest_tweet containing the files mw_lt_admin.css, which controls the presentation of the settings page; and Michal Migurski's json.php, which provides JSON functionality if your server doesn't have PHP5 (like mine). Thanks, Michal!

Upload all that to your wp-plugins directory, or upload the archive and unzip it there if you prefer that, and then go to the Plugins page and activate the plugin. Hooray! But you're not ready to go yet, because two things have to happen, although they can happen in either order.

Replacement String Reference

These are all the bits of data returned via the Twitter API when you make a JSON call. Most of them are trivial or useless for the intended purpose of this plugin, but hey, they're here if you want 'em.

Note that the all-uppercase format of these strings is required. If you put in %%text%% instead of %%TEXT%%, you're going to get back the %%text%% instead of the text of the tweet.


The actual tweet, such as "Headed to lunch now" or "Just saw 'Indiana Jones and the Kingdom of the Crystal Skull' -- OMGWTFBBQSAUCERMEN?!?!?!?". Like that.


The time the tweet was received by Twitter. If you have the "human time" option set to "Yes", the result will be in that fashion (e.g., "six minutes ago"). If it's set to "No", you'll get the raw time string reported by Twitter, which is sort of but not quite the RFC 2822 format.


The status ID of the tweet. For example, if the tweet's URL is http://twitter.com/meyerweb/statuses/817596203, then the status ID is 817596203.


The place from which the tweet was sent. For example, if you post a tweet by going to your page on twitter.com and using the big textarea there, then the source will be "web". Note that this can be a whole set of XHTML. For example, the source value for posts from Twitterrific is (at least as of this writing) <a href=\"http:\/\/iconfactory.com\/software\/twitterrific\">twitterrific<\/a>.


If the tweet is in reply to someone else's tweet, this is the ID (status number) of that someone else's tweet. Thus, if your tweet responded to http://twitter.com/meyerweb/statuses/817596203, then this value is 817596203.


If the tweet is in reply to someone else's tweet, this is the ID of that someone else. This is their numeric ID, not their "screen name".


Your name; e.g., "Eric A. Meyer".


Your account name; e.g., "meyerweb".


The number of people following you on Twitter.


If you have a profile image, then this is its URL.


The "describe yourself in 160 characters or less" biographical information from your Twitter settings.


The "More Info URL" you gave in your Twitter settings; e.g., "http://meyerweb.com/".


Your geographic location, assuming you gave it to Twitter in the first place.


The numeric ID of the your account.

For those who are programming-minded, here's a single tweet from the JSON file Twitter hands over, lightly edited and reformatted to make reading it easier.

"source":"<a href=\"http:\/\/iconfactory.com\/software\/twitterrific\">twitterrific<\/a>",
     "name":"Eric A. Meyer",
     "description":"Web standards | (X)HTML | CSS | microformats | community | writing | speaking | signing man.",
"text":"My needs : TwitterTools :: parking violation : Peacekeeper MX",
"created_at":"Thu May 22 17:13:57 +0000 2008"