Search code examples
twitteroauthtitanium

titanium send tweets from within my app


I've been trying to social features to my app, recently working on sending tweets, I created a twitter application and trying to use birdhouse.js. I get "authorize application" popup, when I click it I get forwarded to another page that displays a pin "from twitter", but no tweets are sent :(

My code is below:

Ti.include('lib/birdhouse.js');

//create your twitter session and post a tweet
function postToTwitter() {
    var BH = new BirdHouse({
        consumer_key : "*****************",
        consumer_secret : "*****************",
    });

    if (!BH.authorized) {
        //call the birdhouse authorize() method
        BH.authorize();
    } else {
        message = 'test test test';
        BH.tweet(message, function() {
            alertDialog = Ti.UI.createAlertDialog({
                message : 'Tweet posted!'
            });
            alertDialog.show();
        });
    }
}

var buttonTwitter = Titanium.UI.createButton({
    width : 280,
    height : 35,
    top : 375,
    left : 20,
    title : 'Send Via Twitter'
});

buttonTwitter.addEventListener('click', function(e) {
    postToTwitter();
});

win1 = Ti.UI.createWindow({
    height : '480',
    width : '100%',
});

win1.add(buttonTwitter);
win1.open();

Solution

  • Have u tried this code

    https://github.com/aaronksaunders/test_social

    thanks