sholsinger.com

Categories Photography Résumé About Me

Twitter Tools Doesn't Display Recent Tweets

11 Mar 2009

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</code> table in the database. Keep reading for the how-to.

[caption id="attachment_177" align="alignright" width="270" caption="Twitter Tools Plugin Version Number"]Twitter Tools Plugin Version Number[/caption]

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</a> Be sure to replace the 1.6 portion with whatever version you're using. Look within the method named: aktt_install</code>. 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
</code></pre>
The above section contains two variables which will be replaced at run-time. The first, $wpdb->aktt</code>, is set a few lines above the snippet containing the query. The second, $charset_collate</code> 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";
  }
}</code></pre>
The above would usually</strong> make $wpdb->aktt</code> 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</code> is set in the lines following $wpdb->aktt</code>. Most</strong> of the time we can assume that we're going to use line 93. Which would (in most cases</strong>) set $charset_collate</code> 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</code></pre>
[caption id="attachment_178" align="alignleft" width="300" caption="The Update Tweets button"]The Update Tweets button[/caption]

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</code>. If you're using phpMyAdmin, refer to this forum post: http://community.mybboard.net/showthread.php?tid=4720</a>. 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.

[caption id="attachment_182" align="aligncenter" width="286" caption="Twitter Tools Working Properly"]Twitter Tools Working Properly[/caption]

Filed under

Comments
  • David 2012-04-04 12:54:01 -0400

    Thank you so much for this well-explained and well put together account. Fixed the problem for me. I knew it hadn't created the table but this article showed exactly how to recify it. Excellent.

  • sam2933 2012-04-21 14:01:40 -0400

    Hello, thank you for this useful tips but it doesn't work for me. Either I update or Reset Tweets nothing appears... I update Twitter Tools but there isn't a record in MYSQL table...

  • TechNinja 2012-08-25 13:49:22 -0400

    Great article. Thanks! Wonder why the database doesn't create on install. Happened to me on two separate occasions. Weird!

comments powered by Disqus