Identi.ca Tools

twitter_logo_s

Alex King‘s Twitter Tools is a great little WordPress plugin for integrating your Twitter presence with your blog. It can show your latest tweets in a sidebar widget, create a “digest” post daily / weekly with a list of your tweets, and announce your blog posts to your twitter account.

identi.ca

In this post I’ll show you what changes are necessary to make it work with identi.ca instead of Twitter.

Why would you want to do that?

Identi.ca is often described as “an open source twitter” which it is, but it’s also the first instance of the Open Microblogging standard, which I believe will become increasingly important. Where Twitter users all share the same service, and are entirely dependent on Twitter for their ability to reach other, Identi.ca enables subscriptions across services, removing the need for a single point of failure.

Twitter Fail Whale, screenshot by John Rees

Twitter Fail Whale, screenshot by John Rees

In other words, Twitter is a bit like the early days of email, when Compuserve users couldn’t email AOL users, and neither set of users could email the Internet. (I quality that with “a bit” since the Twitter API certainly makes possible clients which can do more than just post to Twitter). Identi.ca (or laconi.ca, as the software project behind identi.ca is called) is more like modern, decentralized, global-address-space email.

When identi.ca first launched, many folks were left stuck between the two alternatives: use identi.ca, which was more open and federated, or stay on Twitter, where a strong, rapidly developing community already existed (and, frankly, where many of the folks you were already talking to and listening to were unlikely to be persuaded to move en masse).

Evan Prodromou of Laconi.ca (photo by Zach Copley)

Evan Prodromou of Laconi.ca (photo by Zach Copley)


Now, however, identi.ca can be set to automatically cross-post to Twitter. Still doesn’t remove the need to “watch” two streams, but at least you only need to post one place. (Services like ping.fm are often used in this way as well, to move posts between Twitter, identi.ca, Jaiku, etc).

This ability means that for me, a version of Twitter Tools which would post to identi.ca (and let identi.ca cross-post to Twitter) was preferrable. Luckily, identi.ca has also implemented an API which responds to the same commands in the same way as the Twitter API.

This means that the changes needed are very simple.

In version 1.5.1a of Twitter Tools, lines 67-72 define the API endpoints to be used:


define('AKTT_API_POST_STATUS', 'http://twitter.com/statuses/update.json');
define('AKTT_API_USER_TIMELINE', 'http://twitter.com/statuses/user_timeline.json');
define('AKTT_API_STATUS_SHOW', 'http://twitter.com/statuses/show/###ID###.json');
define('AKTT_PROFILE_URL', 'http://twitter.com/###USERNAME###');
define('AKTT_STATUS_URL', 'http://twitter.com/###USERNAME###/statuses/###STATUS###');
define('AKTT_HASHTAG_URL', 'http://search.twitter.com/search?q=###HASHTAG###');

The key is to change these to map to the corresponding identi.ca API endpoints:


define('AKTT_API_POST_STATUS', 'http://identi.ca/api/statuses/update.json');
define('AKTT_API_USER_TIMELINE', 'http://identi.ca/api/statuses/user_timeline.json');
define('AKTT_API_STATUS_SHOW', 'http://identi.ca/api/statuses/show/###ID###.json');
define('AKTT_PROFILE_URL', 'http://identi.ca/###USERNAME###');
define('AKTT_STATUS_URL', 'http://identi.ca/notice/###STATUS###');
define('AKTT_HASHTAG_URL', 'http://identi.ca/###HASHTAG###');

For the most part, this just means replacing ‘twitter.com’ with ‘identi.ca/api’ except that the individual post urls and hashtag url have to be handled differently.

If you’re planning to use the sidebar widget, which includes a link to hashtags when you use them in a notice. , you’ll also need to find this line:

$hashtag = urlencode('#' . $hashtag);

And change it to:

$hashtag = urlencode($hashtag);

Finally, I also chose to update the “give credit” line, which occurs in two places in the code (not to remove credit for Twitter Tools but to point out the changes):

First, at roughly line 403 (this one is used in the blog post digest of tweets):

$content .= '<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a>.</p>';

I changed that to:

$content .= '<p class="aktt_credit">Powered by <a href="http://www.openparenthesis.org/2009/01/25/identica-tools">Identi.ca Tools</a>, a modified version of <a href="http://alexking.org/projects/wordpress">Twitter Tools</a>.</p>';

And again later at line 768 (this is the one used in the sidebar widget):

$output .= '<p class="aktt_credit">Powered by <a href="http://alexking.org/projects/wordpress">Twitter Tools</a>.</p>';

Which I changed to:

$output .= '<p class="aktt_credit">Powered by <a href="http://www.openparenthesis.org/2009/01/25/identica-tools">Identi.ca Tools</a>, a modified version of <a href="http://alexking.org/projects/wordpress">Twitter Tools</a>.</p>';

This same approach could also be leveraged for other laconi.ca based sites with little effort.

Remember that these changes will get overwritten if you upgrade to newer versions of the Twitter Tools plugin.

(Here’s my modified copy of twitter-tools.php – just change the extension back to .php)

Did you like this? Share it:
12 Comments. Leave a comment or send a Trackback.
  1. Pingback
    Trackback: glynmoody (Glyn Moody) • January 25 2009

    glynmoody (Glyn Moody)

  2. Pingback
    Trackback: stavp (Stav Prodromou) • January 26 2009

    stavp (Stav Prodromou)

  1. #2 • Onur said on January 26 2009:
     

    The daily/weekly digest feature of Twitter Tools is great—if it worked properly. I’ve been testing that functionality for a couple of weeks now, and have not been able to reliably publish digests yet. It’s supposed to be an experimental feature so I don’t blame the developers, but what it promises is so great that I just wish it worked. Still trying though.
    -o

  2. #4 • Jonathan said on February 3 2009:
     

    Can you explain how you added a link to the source client, like this:
    http://identi.ca/notice/1971591

    Is there documentation for this somewhere?

  3. #5 • John said on February 3 2009:
     

    Two parts to the question, really:

    Where to set the “source” in the Twitter Tools code
    How to get Identi.ca to recognize that “source”

    For the first, see lines 403, 620 (which actually sets the useragent doing the posting to the server), and 768 in the file attached to this post.

    For the second, I believe the Laconica code base just stores a set of strings and corresponding URLs for the “source” of a given “notice” posted to a Laconica site. See my question and Evan’s response.

  4. #6 • Jonathan said on February 3 2009:
     

    Thanks. I was referring to the URL for a source. Still a little confused by Evan’s response though. So do I just need to file a bug with Laconica to get a URL added for a string? Thanks a lot for your help!

  5. #7 • John said on February 3 2009:
     

    Yes – or email Evan with what ‘tag’ you are sending as source and what url you want associated with it.

  6. #8 • dudenhofer said on February 10 2009:
     

    Hi John, any reason why you wouldn’t use a ‘ping this’ plugin from Ping.fm for easy posting to both of these? I’m curious what your thoughts are on that.

  7. #9 • John said on February 10 2009:
     

    @dudenhofer – Actually Identi.ca can automatically cross post to Twitter. So when I post to Identi.ca (through the web, through a client, or through this script) it automagically gets cross posted to Twitter.

    One certainly could use ping.fm to accomplish the same goal, or use RSS To Twitter type tools which read your RSS feed as well.

  8. #10 • Don Salva said on March 11 2009:
     

    How do I use it when I don’t have a login/pw but use OpenID (from wordpress username.wordpress.com)?

  9. #11 • John said on March 11 2009:
     

    Hey Don – replied on another post as well.

    Afraid you do need to have a userid/pass – Identi.ca lets you have a userid/pass but also assciate your openid to that account.

    I set up my account first (get a username and pass) and then associated an openID to it, so I’m not sure how to do it the other way round (set up an openID and then get a userid and pass).

  10. #12 • Deep Soni said on June 25 2011:
     

    Hey John, I may be digging an old post but do you know of anything that integrates logins of StatusNet (aka Identi.ca) with WordPress?