Skip to content

Instantly share code, notes, and snippets.

@tango238
Created June 7, 2011 16:20
Show Gist options
  • Save tango238/1012592 to your computer and use it in GitHub Desktop.
Save tango238/1012592 to your computer and use it in GitHub Desktop.
Ti.App.twitterApi
Ti.include("lib/twitter_api.js");
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win = Titanium.UI.createWindow({
title:'twitter timeline viewer',
tabBarHidden:true,
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
window:win
});
var tableView = Ti.UI.createTableView();
win.add(tableView);
tabGroup.addTab(tab1);
tabGroup.open();
(function(){
//initialization
Ti.App.twitterApi = new TwitterApi({
consumerKey:'',
consumerSecret:''
});
var twitterApi = Ti.App.twitterApi;
twitterApi.init();
//get tweets
twitterApi.statuses_home_timeline({
onSuccess: function(tweets){
tableView.setData([]);
for(var i=0;i<tweets.length;i++){
var tweet = tweets[i];
var row = Titanium.UI.createTableViewRow({
height:'auto'
});
var photo = Titanium.UI.createImageView({
image:tweet.user.profile_image_url,
width:64,height:64,
top:5,left:5,
borderRadius:5
});
var name = Titanium.UI.createLabel({
text:tweet.user.name,
left:75,
top:5,
height:'auto'
});
var text = Titanium.UI.createLabel({
text:tweet.text,
left:75,
top:30,
height:'auto'
});
row.add(photo,name,text);
tableView.appendRow(row);
}
},
onError: function(error){
Ti.API.error(error);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment