TwitAPI.js sample
Update status
Get Home TL
Source
function byId(id) {
return document.getElementById(id);
}
function escape(str) {
return str.replace('&', '&').replace('"', '"').replace('<', '<').replace('>', '>');
}
window.onload = function() {
var api = new TwitAPI();
byId('update').onclick = function() {
var status = byId('status').value;
if (status.length == 0) {
return;
}
var callback = function() {
alert('DONE!');
}
var params = {'status': status};
api.call('post', 'statuses/update', callback, params);
}
byId('getHome').onclick = function() {
api.call('get', 'statuses/home_timeline', function(statuses) {
var html = '';
for (var i=0; i<statuses.length; i++) {
var status = statuses[i];
html += escape(status.user.name) + ' : ' + escape(status.text) + '<br />';
}
byId('result').innerHTML = html;
});
}
}