Twitter Tools Doesn’t Display Recent Tweets

Mar 11

Is Twitter Tools not working for you? Maybe you downloaded Twitter Tools through the WordPress UI? Perhaps the ‘activation’ didn’t work out properly and the local cache database table wasn’t created. At this point, the installation is broken. Don’t worry, it isn’t that hard to fix. All we have to do is set up the ak_twitter table in the database. Keep reading for the how-to.

Twitter Tools Plugin Version Number

Twitter Tools Plugin Version Number

Prerequisites: You need to have access to run SQL queries directly to the MySQL database server. This could be via the command line mysql client or even phpMyAdmin. Second, you need to know which version of Twitter Tools is installed. To find out, navigate to the WordPress Installed Plugins Management interface. Next to ‘Twitter Tools’ you should see the version number. Mine happens to say 1.6. Now that we know what version we need, we’ll need to grab some code from the Twitter Tools Trac system. Navigate to: http://plugins.trac.wordpress.org/browser/twitter-tools/tags/1.6/twitter-tools.php Be sure to replace the 1.6 portion with whatever version you’re using. Look within the method named: aktt_install. Which in version 1.6 starts on line 85.

You’re looking for the section that looks like the SQL Query to create the table. See the example from version 1.6 below:

CREATE TABLE `$wpdb->aktt` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`tw_id` VARCHAR( 255 ) NOT NULL ,
`tw_text` VARCHAR( 255 ) NOT NULL ,
`tw_reply_username` VARCHAR( 255 ) DEFAULT NULL ,
`tw_reply_tweet` VARCHAR( 255 ) DEFAULT NULL ,
`tw_created_at` DATETIME NOT NULL ,
`modified` DATETIME NOT NULL ,
INDEX ( `tw_id` )
) $charset_collate

The above section contains two variables which will be replaced at run-time. The first, $wpdb->aktt, is set a few lines above the snippet containing the query. The second, $charset_collate is set immediately after the first. See the example snippet below.

$wpdb->aktt = $wpdb->prefix.'ak_twitter';
$charset_collate = '';
if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
  if (!empty($wpdb->charset)) {
    $charset_collate .= " DEFAULT CHARACTER SET $wpdb->charset";
  }
  if (!empty($wpdb->collate)) {
    $charset_collate .= " COLLATE $wpdb->collate";
  }
}

The above would usually make $wpdb->aktt equal to: ‘wp_ak_twitter’. However, you should mind the table prefix setting you used when setting up your WordPress blog. The second variable, $charset_collate is set in the lines following $wpdb->aktt. Most of the time we can assume that we’re going to use line 93. Which would (in most cases) set $charset_collate equal to: ‘ DEFAULT CHARACTER SET utf8′. However, this only applies if you are using MySQL 4.1.0 or higher. If that is not the case, you’ll need to figure out what collation your WordPress installation is using. If we use the ‘average case’ example, which is exactly what I’m using, the query becomes:

CREATE TABLE `wp_ak_twitter` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`tw_id` VARCHAR( 255 ) NOT NULL ,
`tw_text` VARCHAR( 255 ) NOT NULL ,
`tw_reply_username` VARCHAR( 255 ) DEFAULT NULL ,
`tw_reply_tweet` VARCHAR( 255 ) DEFAULT NULL ,
`tw_created_at` DATETIME NOT NULL ,
`modified` DATETIME NOT NULL ,
INDEX ( `tw_id` )
) DEFAULT CHARACTER SET utf8
The Update Tweets button

The Update Tweets button

Now, we need to execute that query in either phpMyAdmin or the mysql command line client. I’ll assume you know how to do at least one of those. If you’re on unix/linux/mac execute the following command for help: man mysql. If you’re using phpMyAdmin, refer to this forum post: http://community.mybboard.net/showthread.php?tid=4720. As long as you haven’t received any errors, the table should be created and Twitter Tools should begin working as expected. It may, however, need some help to get itself back on track. You can give Twitter Tools a bit of a nudge by going to the Twitter Tools Settings page in your WordPress Admin site. Click the button near the bottom that is labeled, “Update Tweets”.

At this point Twitter Tools should be displaying your recent Tweets on your blog. However, if you have caching enabled, it may take a while for that page to be re-cached. Alternatively, you may need to do a full refresh in your browser. IE-style browsers use Ctrl+F5 for this. Firefox for Windows and Linux does so as well. Firefox and Safari on Mac use Cmd+R because Ctrl+F5 enables VoiceOver in OS X.

Twitter Tools Working Properly

Twitter Tools Working Properly

 

Leave a Reply