Documentation
JSON
For more information about JSON go to http://json.org/.
Where can you get JSON
Here's the magic list of URLS you can access:
http://devku.jaiku.com/json http://devku.jaiku.com/feed/json http://devku.jaiku.com/contacts/feed/json?user=[Your nick]&personal_key=[Your key]
Adding Callback
Like Yahoo and del.icio.us, the callback parameter can added for wrapping the JSON output in parentheses and your function name:
http://devku.jaiku.com/feed/json?callback=hello
Example Response
Example output from Devon's stream:
{
"title" : "Jaiku | Latest from Devon",
"url": "http://jaiku.com",
"stream": [
{
"id": "329142",
"title":"Oo, I\'m so secret.",
"content": "Hidden Jaiku Lair, Helsinki",
"icon": "http://jaiku.com/images/icons/web-snorkeling.gif",
"url": "http://devku.jaiku.com/presence/329142",
"created_at": "2007-02-22T01:33:57 GMT",
"created_at_relative": "1 month ago",
"location": "Hidden Jaiku Lair, Helsinki",
"user": {
"avatar": "http://jaiku.com/image/avatar_default_t.jpg",
"first_name": "Devon",
"last_name": "Kubrick",
"nick": "devku",
"url": "http://devku.jaiku.com"
}
}
]
};
Example JavaScript
Want to get your jaikus to your blog with custom design? Example is influenced by John Resig's Google Homepage example.
Create script tag dynamically (with callback show):
var url = "http://devku.jaiku.com/feed/json";
function load(){
var head = document.getElementsByTagName("head")[0];
script = document.createElement("script");
script.type = "text/javascript";
script.src = url + "?callback=show";
head.appendChild(script)
}
Add callback function show:
function show(json) {
var c = document.getElementById("jaikus");
var uls = c.getElementsByTagName("ul");
if (!uls.length)
var ul = document.createElement("ul");
else
var ul = uls[0];
for (var i=json.stream.length-1; i >= 0; i--) {
var entry = json.stream[i];
var id = "jaiku-" + entry.id;
if (!document.getElementById(id)) {
var li = document.createElement("li");
li.id = id;
// User
var user = document.createElement("a");
user.setAttribute('href', entry.user.url);
user.appendChild(document.createTextNode(entry.user.nick));
// Entry link & title
var post = document.createElement("a");
post.setAttribute('href', entry.url);
post.appendChild(document.createTextNode(entry.title));
li.appendChild(user);
li.appendChild(document.createTextNode(": "));
li.appendChild(post);
ul.insertBefore(li, ul.firstChild);
}
}
c.appendChild(ul);
}
Add callback function show:
window.onload = load; setInterval( load, 1000 * 30);
Add container element to your HTML and style it:
<div id="jaikus"></div>