all posts

Make Jaiku presence updates programmatically

Published to Blog on 16 Oct 2007
A couple of weeks ago I wrote post about updating your Twitter timeline using the Twitteroo Core API. Recently I dug into the Jaiku API to learn how to do the same. The Jaiku API docs don't offer many examples or details, but the basics are explained and enough is presented to get you on the right track into some experimentation.

I couldn't find a handy third party library for working with Jaiku in .NET so this time around I had to do the dirty work myself. There is not much to it, basically make a post to api.jaiku.com/json with the following parameters:

user=YourUserName&personal_key=YourAPIKey&method=presence.send
&message=your+message+goes+here


The .NET (C#) code needed to make this post looks something like this:

string result;
string post = @"method=presence.send&user=YourUserName&personal_key=YourAPIKey
    &message=your+message+goes+here";

           
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.jaiku.com/json");
request.Method = "POST";
request.ContentLength = post.Length;
request.ContentType = "application/x-www-form-urlencoded";
Stream reqStream = request.GetRequestStream();
reqStream.Write(post, 0, post.Length);
reqStream.Close();

using (HttpWebResponse response = ((HttpWebResponse)objRequest.GetResponse())) {
    using (Stream respStream = response.GetResponseStream()) {
        using (StreamReader reader = new StreamReader(respStream, Encoding.UTF8)) {
            result = reader.ReadToEnd();
            //check result for "status":"ok"
            //if not then throw your exception or return unsuccessful
               }
    }
}

 



Dan Hounshell
Web geek, nerd, amateur maker. Likes: apis, node, mobile, motorcycles, watches, food, Nashville, Savannah, Cincinnati and family. Dislikes: mean people
Dan Hounshell on Twitter