WordPress Tools: MW Latest Tweet

Installation

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.

%%TEXT%%

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

%%CREATED_AT%%

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.

%%ID%%

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.

%%SOURCE%%

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>.

%%IN_REPLY_TO_STATUS_ID%%

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.

%%IN_REPLY_TO_USER_ID%%

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".

%%USER_NAME%%

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

%%USER_SCREEN_NAME%%

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

%%USER_FOLLOWERS_COUNT%%

The number of people following you on Twitter.

%%USER_PROFILE_IMAGE_URL%%

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

%%USER_DESCRIPTION%%

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

%%USER_URL%%

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

%%USER_LOCATION%%

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

%%USER_ID%%

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.

"truncated":false,
"in_reply_to_user_id":null,
"in_reply_to_status_id":null,
"source":"<a href=\"http:\/\/iconfactory.com\/software\/twitterrific\">twitterrific<\/a>",
"id":817596203,
"user":
     "name":"Eric A. Meyer",
     "description":"Web standards | (X)HTML | CSS | microformats | community | writing | speaking | signing man.",
     "url":"http:\/\/meyerweb.com\/",
     "screen_name":"meyerweb",
     "id":646533,
     "location":"USA",
     "protected":false,
     "followers_count":2880,
     "profile_image_url":
        "http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/19322632\/eric-mystery_normal.jpg"
"text":"My needs : TwitterTools :: parking violation : Peacekeeper MX",
"favorited":false,
"created_at":"Thu May 22 17:13:57 +0000 2008"