Skip to content

Instantly share code, notes, and snippets.

@mogya
Created January 18, 2011 12:23
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 mogya/784359 to your computer and use it in GitHub Desktop.
Save mogya/784359 to your computer and use it in GitHub Desktop.
Ti.include('lib/oauth_adapter.js');
var oAuthAdapter = new OAuthAdapter(
'YOUR CONSUMER SECRET',
'YOUR CONSUMER KEY',
'HMAC-SHA1'
);
// load the access token for the service (if previously saved)
oAuthAdapter.loadAccessToken('twitter');
//OAuth if need.
if (oAuthAdapter.isAuthorized() == false)
{
var receivePin = function() {
oAuthAdapter.getAccessToken('https://api.twitter.com/oauth/access_token');
oAuthAdapter.saveAccessToken('twitter');
};
// show the authorization UI and call back the receive PIN function
oAuthAdapter.showAuthorizeUI('https://api.twitter.com/oauth/authorize?' +
oAuthAdapter.getRequestToken('https://api.twitter.com/oauth/request_token'), receivePin);
}
//get timeline
oAuthAdapter.send({
url:'https://api.twitter.com/1/statuses/home_timeline.json',
parameters:[
],
method:'GET',
onSuccess:function(response){
alert('got tweets.see info log.');
response = JSON.parse(response);
for(var i=0;i<response.length;i++){
var tweet = response[i];
Ti.API.info(tweet.user.name+':'+tweet.text);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment