May 10th, 2007 by rick

API Example: IMified Integration

1 comment on 518 words

I’ve begun the process of implementing and documenting the Lighthouse API, but I wanted to show a simple example with IMified. IMified runs IM bots for the major services and provides some basic services like note taking, todos, etc. What’s interesting is that they provide hooks for a lot of popular services, as well as a developer API.

The API involves setting up an endpoint somewhere that responds to HTTP POST requests from IMified. Each POST request increments a step variable, while sending return values from the previous steps. Here’s some pseudo code from their API:

if step = 1
---What is your first name?
elseif step = 2
---What is your last name?
elseif step = 3
---Hi #value1# #value2#|I'm a basic widget!
else
---All done!
endif

I looked at this through my red ruby goggles and came up with this:

step do
  "What is your first name?"
end

step do
  "What is your last name?"
end

step do |value, params|
  "Hi #{params['value1']} #{value}\nI'm a basic widget!"
end

Using this as inspiration, I hacked out a small ruby library to use the IMified library. It just so happened though, that the IMified AOL bot was taking a personal day off, so I had to rely on my own comprehension of the API and unit tests to get me through it.

Fast forward a week later when I started getting the API documentation in place. I really wanted a basic example, so I figured I’d write an IMified widget. To prove a point, I implemented it as a separate Mongrel handler, on a separate server, attached to a Mephisto mongrel, using the Lighthouse API ruby lib.

If you want to try it out, set up an IMified widget using http://lighthouseapp.com/imified/list_tickets as the URL. From there, you should be taken to a Lighthouse page where you’ll enter your Lighthouse token, account name, and and project id. If you just want to live vicariously, I recorded a quick screencast showing it in action. Here’s the source for the ruby handler I’m using.

Update: Okay, IMified fixed the bug with Advanced Widgets, so this should work now.

Discussion

  1. Joshua Sierles Joshua Sierles said on May 18th

    Coooool

Sorry, comments are closed for this article.