Monday, November 30, 2009

Updating your Lotus Connections microblog programmatically

View Comments

This post is very techie. It comes as a reader recently asked me to share the code that I use to programmatically update my microblog (or status) in Lotus Connections. The following code is using Java and Abdera, but should be easily portable to other platforms like Adobe AIR. The Lotus Connections Profiles API documentation was helpful when I was trying to figure this out.

  1. Initialize the Abdera library
    // Initialize the Atom Client to update the status in Connections
    Abdera abdera = new Abdera();
    AbderaClient client = new AbderaClient(abdera);
    client.addCredentials("", null, null, new UsernamePasswordCredentials(username, password));
    catch (URISyntaxException e)
  2. Create the Atom entry to post to Lotus Connections

    Parser parser = abdera.getParser();
    String urlText = "" + username;
    // Create the Atom entry with the new status message
    Entry status = abdera.newEntry();
    status.addCategory("", "entry", null);
    status.addCategory("", "status", null);
    message = StringEscapeUtils.escapeHtml(message);

  3. Post the Atom entry
    // Send the new status message to Connections
    ClientResponse response = client.put(urlText, status);
  4. Check the return code
    if (response.getType() == ResponseType.SUCCESS)
    // yipee
    System.out.println("woo hoo");
    // WTH?
    System.out.println("oh no!");

Hope this helps.

blog comments powered by Disqus