Search code examples
twitteroauthauthorizationtitaniumappcelerator

Appcelerator Titanium: Authorization to get tweets


Does anyone know how to get tweets when you have to be authorized? I am able to post tweets, which is done by the oAuth Adaptor, but this doesn't have a GET method (only SEND).

I am trying to use the count parameter in the user_timeline. It doesn't require when i only use the SCREEN_NAME parameter, but when i use the COUNT parameter it needs authentication.

Can anyone help me with this?

Thanks!


Solution

  • i found this. it's not my code, but maybe it helps. thanks @kosso ([email protected])

    function getTweets(screen_name){
    
        // create table view data object
        var data = [];
    
        var xhr = Ti.Network.createHTTPClient();
        xhr.timeout = 1000000;  
        xhr.open("GET","http://api.twitter.com/1/statuses/user_timeline.json?screen_name="+screen_name);
    
        xhr.onload = function()
        {
            try
            {
                var tweets = eval('('+this.responseText+')');
    
                for (var c=0;c<tweets.length;c++){
    
                    var tweet = tweets[c].text;             
                    var user = tweets[c].user.screen_name;
                    var avatar = tweets[c].user.profile_image_url;
                    var created_at = prettyDate(strtotime(tweets[c].created_at));
    
                }
    
            }
            catch(E){
                alert(E);
            }
        };
        // Get the data
        xhr.send();