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();
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
}
}
}
















Comments,