• Zeth will be attending PyCon UK on the 12th to 14th September 2008.

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:

http://media.commandline.org.uk/images/posts/other/identica.png

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.

1 Daniel Black says...

Hey, sounds good already. There's another Python script for command-line 140-character-messaging (won't call it "tweeting" for obvious reasons), Tweety Py, that's currently languishing. Not, I think, because the developer's disinterested, but rather because he's busy, which is cool.

I'll pick this up and give it a shot. If I had the chops (I don't), I'd like to make a command-line app that works across multiple services. I'm not leaving Twitter for Identi.ca--they're just different crowds right now. But it's harder to keep up with one or the other depending on where I am.

So, thanks, and I'll submit feedback.

Posted at 4:55 p.m. on September 3, 2008


What do you have to say?

Show Editing Help


PyCon UK

About

Hello, my name is Zeth, I'll be your host here.

Command Line Warriors is about taking control of your own technology, it looks at our experiences of computing; especially using GNU/Linux, the Python programming language, the command-line and issues such as techno-ethics, best practices and whatever is cool now. If you take control of your technology then you are a Warrior too!

This site is your site too which means that you can contribute and get involved. You can leave comments using the facility provided. For me, the comments and discussions are by far the best part of the site. So please do have your say!

Latest Discussions

Tringi

December 1, 2008
Hi, I am far from your league, but instead of [20. Nd5], why not just play Qd8? :-) Wouldn't it be only Qd8 Qd8 then, or am I missing something?
Ruy Lopez, Berlin defence, open variation part three

Tringi

November 30, 2008
...oh, I meant "Qe8 Qe8" in my previous post, sry ;-)
Ruy Lopez, Berlin defence, open variation part three

Cruze

November 29, 2008
Buy discount professional health products online.
Include ODF support in the Linux Standard Base?

Mike

November 29, 2008
>The most useful xmlstarlet tool for me has been the XML validator, >which tests whether your documents are well formed or not. You >use the tool as follows: >xmlstarlet val ...
My God, it's Full of XML

Giacomo

November 29, 2008
Er, "elif test `ls "$with_xqilla"/libxqilla*.so 2>/dev/null | wc -l` -gt 0 ; then" should now be "elif test `ls "$with_xqilla"/libxqilla.so* 2>/dev/null | wc -l` -gt 0 ; then", as the ...
Native XML storage with Berkeley DB XML - part one

Felipe Coury

November 23, 2008
What do I have to say? Only this: "THANK YOU"! Awesome!
SFTP in Python: Really Simple SSH

fmv

November 19, 2008
just a real db SAMPLE please
Native XML storage with Berkeley DB XML - part one

Very helpful

November 12, 2008
but i need more help. I'm have to execute the sudo command after I log in. What do I need to do to enter the password after the sudo command ...
SFTP in Python: Really Simple SSH

blz

November 12, 2008
I buy 99% of PEP8, except: I don't like the line spacing rules... I can't read the code when it's too close together - it looks congested and I can't ...
Twelve commandments for Beautiful Python code

Zeth

November 11, 2008
Hi Ioxs, I said above *"I will give an example of a standard directive, then an example of a third-party directive"*, so the image directive is the example of a ...
An Introduction to ReStructuredText

loxs

November 9, 2008
Hello, Are you sure about the sourcecode directive, because I didn't manage to make it work. And it doesn't work with the online renderers too.
An Introduction to ReStructuredText