Scripting MicroBlogs

I know I am way late to the party on this but I just finished rolling some little scripts to make updating both Twitter and Identi.ca with one action easier for me.

When I first started using Twitter, I tried playing around with some suggestions for building scripts to allow sending text from Quicksilver to that service. I could never quite get that working right, probably because I just didn’t read the examples closely enough and was missing something key. Regardless, as neat a hack as that was, it didn’t make sense when I was only using a single micro blogging service.

At the encouragement of some other open source/open media folks, I’ve been playing with Identi.ca. It is more than just a Twitter workalike though it is also that. All of its code is available under the GPL, it actually uses the Laconica project. The service itself runs under the new GNU Affero license for web services. All of the status text is licensed under a CC 3.0 BY license. Free as in speech through and through.

It still lacks some features that Twitter possesses but Evan and the developers are working hard on features and improving scalability. With respect to the latter, Identi.ca is designed to be federated and the Laconica code supports the Open Micro Blogging protocol which promises to weld together status updates across multiple service instances that support the protocol.

To better understand what that means think of the way email works, that everybody has their own domain after the at symbol that usually is handled by a distinct server or set of servers. Unlike Twitter, you do not have to be on the same email server to exchange messages. Identi.ca promises the same sort of better distribution as email, that you could pick and choose whichever micro blogging server or service you want and use the supported protocol to subscribe to status updates for users on other servers.

It’s an ambitious plan and I wish the fine folks at both Control Yourself, Inc. (that operate Identi.ca) and Laconica the best of luck in realizing that potential.

So back to my own script hacking. I enjoy Twitter because all of my friends are already on it. I am excited about Identi.ca because of the technology differences from Twitter and many movers and shakers in the open source/free software and open media worlds are showing up there. With a couple of client options for each service, getting updates is easy and low stress. However, the prospect of logging into each service to update or using two different clients strikes me as a pain.

Sure, there is Twhirl. Except that I cannot stand AIR based applications. They are universal ugly and unusable. They seem to have forgotten the lesson Java taught us about write once, suck everywhere *for desktop applications*. (I say this as a paid Java developer, *for server applications*.) I am sure there are web services I could use that would allow me to post to multiple services at once but that requires giving them my password which I prefer not to do. Yeah, yeah, I use unique passwords for everything and its just a couple of social applications, but still.

So back to my aborted attempts to create a script I can invoke from Quicksilver. I figured out how to bash through the web interface and API for Identi.ca and Twitter respectively from the command line. I threw a couple of shell scripts around that, then an AppleScript to make invoking them easier from QuickSilver.

Here are my scripts, with blanket permission to re-use with no strings attached but also provided as-is (don’t pester me for support).

twitter.bash
#!/bin/bash

new_message=${1}

curl -k \
--basic \
--user username:password \
--data "status=${new_message}" \
--output /dev/null \
https://twitter.com/statuses/update.xml
identica.bash
#!/bin/bash

new_message=${1}

curl --data "nickname=username" \
--data "password=password" \
-c ~/.cookies.txt \
-o /dev/null \
http://identi.ca/main/login

curl --data "status_textarea=${new_message}" \
-b ~/.cookies.txt \
-c ~/.cookies.txt \
-o /dev/null \
http://identi.ca/notice/new

Evan says Identi.ca should have SSL on their login page, soon-ish. I prefer to use that, if available, but am happy enough to wait considering all the other hard work he and his peers are doing.

To Status.scpt
using terms from application "Quicksilver"
	on process text t
		if length of quoted form of t > 140 then display dialog "Message too long: " & quoted form of t
		do shell script "/Users/user/bin/identica.bash " & quoted form of t
		do shell script "/Users/user/bin/twitter.bash " & quoted form of t
	end process text
end using terms from

If you do not use OS X, it should be trivial to write your own wrapper script in your favorite scripting language, maybe Python with a nice GUI binding of some sort, to check the input length and invoke the simpler shell scripts. I also like that the quoted form property in AppleScript’s text class handles quote and apostrophe escaping so the shell scripts don’t have to handle it.

For my own use, I may try to figure out how to get at the Keychain from Applescript so my passwords don’t have to be stored anywhere in the scripts themselves. Otherwise, I am pretty happy with this little set up and with GTalk and Twitterific respectively for receiving updates from Identi.ca and Twitter.

7 Replies to “Scripting MicroBlogs”

  1. Some problem with the identi.ca script. I cannot login – I am getting the error ‘There was a problem with your session token. Try again, please.’ in the return HTML. Any ideas?

  2. Yeah, Identi.ca changed how authentication works to improve security. They are now recommending that you exclusively use the Twitter API to authenticate and post. I’ll post the new version of my script shortly.

  3. Please do post your new script! (The actual script files would be primo!) I’d love to be able to do this, but I don’t have the tech-balls. I’ve got a script hooked up for updating Twitter via Quicksilver, but this is the first identi.ca update script I’ve seen. Bravo!

Leave a Reply

Your email address will not be published. Required fields are marked *