Skip to content

Instantly share code, notes, and snippets.

@stereoket
Created May 19, 2011 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stereoket/981628 to your computer and use it in GitHub Desktop.
Save stereoket/981628 to your computer and use it in GitHub Desktop.
ouath-adapter test
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
Ti.include('sha1.js');
Ti.include('oauth.js');
Ti.include('oauth_adapter.js');
Ti.include('twitter_api.js');
if (oa.oAuthAdapter.isAuthorized() != false) {
oa.oAuthAdapter.send({
url:'http://api.twitter.com/1/account/verify_credentials.json',
parameters:[
],
method:'GET',
onSuccess:function(response){
response = JSON.parse(response);
alert(response.screen_name+' authenticated');
}
});
}
if (oa.oAuthAdapter.isAuthorized() != false) {
oa.oAuthAdapter.send({
url:'https://api.twitter.com/1/statuses/update.json',
parameters:[
'status','tweet on titanium!!'
],
method:'POST',
onSuccess: function(response) {
response = JSON.parse(response);
alert(response.screen_name+' tweet');
},
onError: function(response) {
alert("Error " + response.text);
}
});
} else {
alert("Not in not !!");
}
win1.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment