Using new social networking service Identi.ca from the command line
23 July 2008
Social networking is fickle
Over a year ago, I talked about how I joined Facebook and Mugshot, then as part of my ten crazy New Year predictions, I argued that social networking will eventually become a protocol. Social networking is fickle, as people move on to the next pub.
After Easter, I joined Twitter and I wrote a post about Scripting Twitter with Python, and how I tried to integrate Twitter into my GNOME desktop.
One of the problems I had with Twitter was the API was heavily rate limited, so I would get suspended from the API often when trying to experiment with spidering the social network (e.g. give me all the friends of friends who have mentioned fishing).
A new Identi
The new kid on the block is Identi.ca. Like Twitter, on Identi.ca, you post your latest status update of up to 140 characters, and you can subscribe to other people's updates.
So here is my page on Identi.ca:
Identi.ca is brand new, so not as many people are using it yet as Twitter. As you can see, currently I only have three 'friends' on Identi.ca. If you have a go, do become my virtual friend!
A few differences from Twitter are that Identi.ca's source code is published online (under the name Laconica) and you can use OpenID to login if you want. Also the API is not rate limited and Identi.ca does not currently have the rate problems that Twitter has (Twitter is offline with capacity problems all the time these days).
Identi.ca plan API breakage but that:
'The documented write API below will remain available until at least September 30, 2008' . Source
I wrote my own quick tool for Identi. I was quite impressed how far I got with it in just an hour, my code output in Python is increasing nicely ;-)
It is a command line tool for getting and sending your updates to Identi.ca.
It is less advanced than my Twitter module because the API will change. It doesn't cache anything for example.
To use my tool, you need feedparser on your system. On Ubuntu:
sudo apt-get install python-feedparser
On Gentoo:
sudo emerge feedparser
If you are another platform (e.g. Mac or Windows) and you have Python's Setup tools installed you can go:
easy_install feedparser
Now you need to get my tool. You can download it from my code page, and save it as identi.py. If you have made a script directory then just throw the file in and then call the program with identi.py. Otherwise you can run it with the python command:
python identi.py
This will download the updates from all the friends that you are following. If you have a lot of updates, then you can limit it. The following command will download the latest 10 updates:
python identi.py -n 10
For complete options, run with -h:
python identi.py -h
so we have downloaded messages. Next is uploading a message, for that just write it at the command line:
python identi.py Just saw a great post at http://commandline.org.uk
The Bash shell does not allow unmatched quotes. My program does not care but if you have unmatched quotes then your message won't even get to my program. So if you want to use unmatched quotes then surround the whole thing with single or double quote marks, for example:
python identi.py "Just saw a great post at Zeth's blog http://commandline.org.uk"
Your username and password are asked for when needed. If this gets on your nerves, you can edit the top of identi.py and provide them.
If you know Python you could also use it as a Python binding:
import identi
myid = identi.IdentiCA(username = "zeth", password = "something")
myid.login()
messages = myid.get_messages()
new_message = 'Posting direct from my Python Shell'
myid.put_message(new_message)
That is really about all it does, if you need something more then you may be better off reading the API documentation.



