Posting Messages Using Jaiku API through Ruby console

Jaiku is considered a nice communication method among a group of friends or colleagues in a small company or so. One major strength of jaiku is that it has a lot of notification methods about updates. users can receive notifications through sms, IM or throught jaiku website.

I wanted to take a look at jaiku API. so i can use it in any application to send notifications to the rest of my colleagues. the user uses his username and API key to authenticate operations through the API

Jaiku provides two interfaces that can be used to read/write jaikus. the XML-RPC and the JSON interface. xmlrpc behaved little strangly always responding with "XML-RPC server accepts POST requests only." even when i'm sending POST requests.

i managed to use the json interface though

just send a post request to api.jaiku.com/json with the parameters(username, api key, method, message)

throught Ruby's irb
i can send a note by typing:


irb(main)> require 'net/http'

irb(main)> data = 'user=username&personal_key=999999999&method=presence.send&message=#channel This Message goes to everyone on that channel'

irb(main)> http = Net::HTTP.new('api.jaiku.com')

irb(main)> result = http.post('/json',data)

irb(main)> result.body

=> "{\"status\":\"ok\"}"


I believe this can be a valuable feature for some websites

of course you can make similar functionality through a simple html page with the following code


< form action="http://api.jaiku.com/json" method="post">
      Message to Jaiku< input name="message" type="text" value="">
      < input name="user" type="hidden" value="username">
      < input name="personal_key" type="hidden" value="fd36a832c09ed8765">
      < input name="method" type="hidden" value="presence.send">
      < input type="submit" value="send message">
< /form >


Whatever the way u choose to do this.. an important note is that you have to use the POST HTTP method. and you have to use the method=presence.send of course with your username and personal key

Comments

Popular posts from this blog

Prime Numbers Generator

Success of Startups

Stress Testing with Siege and Bombard, know your limits