Minor setup stuff. I use a G1 phone from T-Mobile and have very much enjoyed the experience. One of the things that I’ve been looing for since I started using it has been a way to post microblogs to http://identi.ca. There are a couple of apps out there for twitter users, and while I do use twitter, it’s had a few problems that make it unsutible in my view for ongoing use.
There really are several different ways of getting content out of identi.ca onto my phone. sms messages, e-mail, web browser, gtalk/xmpp, etc. However I really didn’t want to be reading messages from identi.ca, I’m a bit more interested in sending messages to there.
For me a critical point is that I have a jabber/xmpp server running on one of my own servers. As a matter of fact I had already linked my jabber account there. If you have a gmail account, you might prefer to use that. However a pointer there is that any time you receive an IM at your gmail gtalk account, it very well may be using an sms message to talk to your phone. That can get expensive. I recommend using a server of your own, or getting an account on jabber.org or a public server and use that resource for sending and receiving jabber to identi.ca messages.
Now getting a jabber message from a phone to a jabber server is not really difficult. I suspect that I could install a development package on my desktop, write a bit of code for the android environment, compile a package, put it on a server I have access to, install the package to my phone, test, and repeat the steps from write a bit of code on, until testing gives me the results I expect.
An alternative that has just recently shown up is the Android Scripting Environment. http://code.google.com/p/android-scripting/
With the Android Scripting Environment (ASE) you can write scripts in Bean Shell, Lua, or Python. By default Bean Shell is installed, but you will need to install the interpreters for Lua and Python. The Environment is a .8 code base, which means it is very functional, but may not be complete from the perspective of a general user.
I’ve personally never done well in Java, and Bean Shell really is a scripting environment for Java. If you happen to like Java, it may be all you need. I’ve also never worked with Lua, but from what I see in the collection of scripts that are available as examples, it appears to be a reasonable language as well. I have played around a bit with Python, and while the environment is hardly complete, it seems to be sufficient for what I need. For android, it does include xmpp support, as well as support for pulling down URLs, interpreting html, and a few other elements as well. All I needed this time was the Android support and the xmpp support.
I’ve liberally copied code from a couple of different resources. For an example of how to send a message to a jabber server, (which was not written for the android platform, but it’s python and all the referenced libraries are included in ASE) I used the tutorial at http://snippets.dzone.com/posts/show/618
Here’s the sample:
import android
import xmpp
droid = android.Android()
# User interaction stuff
message = droid.getInput('identi.ca update', "What's Up?")['result']
tag = droid.getInput('tags?','What tags? (Prepend w/#)')['result']
# Varios Variables we will use
_SERER = 'jabber.server.you.use', 5223 # put in your own jabber server name and appropriate port
username = 'your.user.name' # give it the user name you want to use
password = 'your.password' # until I figure out how to store these credentials securely
fullmessage = tag + message # build the message we're going to send. (could use improvement)
destid = 'somename@jabber.server' # for identi.ca use 'update@identi.ca'
# send the message
cnx = xmpp.Client('jabber.server.you.use') # don't need the port so don't use when creating a connection instance to use
cnx.connect( server=(_SERVER) ) # establish a connection
cnx.auth(username,password, 'G1') # authenticate yourself, and give a 'presence' (G1 in this case)
cnx.send( xmpp.Message( destid, fullmessage ) ) # Send the message
# exit 'cleanly'
quit = droid.exit() # we're done, time to go
And that pretty much summs it up. There are a few things I will be investigating over time. I suspect that using a dictionary, I can create a set of ‘tags’ that I want to use regularly (#cvg2009, #c25k, etc.) then feed that to some sort of a pick list, and hopefully I could enter the update and select the appropriate tag all in one dialog. Worst case, 2 dialogs sort of like what I’m doing now. This currently has a bit more flexibility, but in the end I would also like to be able to identify if this is to be a message to update, or to some other specific user.
What am I doing with this? Well, as a department co-head for the 2009 CONvergence convention, I wanted a way to update my facebook, twitter, identi.ca and planet pages with what I’m doing, and what’s happening now. I’m pretty sure that I can update twitter directly, and possibly through that facebook, and it looks like I could import from there to identi.ca, which also would propogate to my world page, but after seeing the problems that twitter has been going through with it’s growing pains, I didn’t think that was the best route. If it works for you, ok. The facebook app for Android has been having problems since facebook changed something recently, so that was out. And it’s been a while since I wrote anything I considered interesting like this, so here it is.
How things work from here. My jabber server accepts a connection and forwards the message to update@identi.ca, which then places the update in my stream. Through the facebook interface it posts an update to facebook. I also have my account configured so that all events are posted to twitter as well. My planet page pulls any updates I’ve made in the past couple of hourse every 2 hours from twitter and identi.ca. Hey it pulls an update that I’ve posted a blog as well. Handy little page at times.
I always seem to discover ‘issues’ that need to be corrected that have almost nothing to do with the specific project at hand, except that they got in the way. Today I discovered I had not punched a hole for tcp through my firewall for jabber clients. I had punched one for UDP, but since nothing is listening for that…
Have fun. If you find the app useful, and want to let me know about updates, I would appreciate hearing about them.