1

I am needing to send a tweet for from my iphone/ipad app using Appcelerator Titanium & javascript. I found the following example on github (code also posted below for this):

https://gist.github.com/2eabc31db388144b3abc

I have created my app details (key,secret etc) in my twitter developer account and using the code from the example i get the twitter login and authorisation popup but once you click authorise, all i get is a webview showing the callback url (that i was required to put in the twitter app settings). So the app is stuck on a webview showing the callback url but does nothing after. If i close the popup window it just goes back to my app without sending a tweet.

Can anyone help?

code in app.js:

var win = Ti.UI.createWindow({ backgroundColor: '#fff' });
var shareButton = Ti.UI.createButton({
    width: 90, bottom: 10, height: 30,
    title: 'Tweet!"'
});
win.add(shareButton);
win.open();

var social = require('social');
var twitter = social.create({
    site: 'Twitter',
    consumerKey: 'XXXXXXXXXXXXXXXX', 
    consumerSecret: 'XXXXXXXXXXXXXXXXXXXXX' 
});

shareButton.addEventListener('click', function() {
    twitter.share({
        message: 'Hello, world!',
        success: function() {
            alert('Tweeted!');
        },
        error: function(error) {
            alert('Oh no! ' + error);
        }
    });
});
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80
Lauren Reynolds
  • 121
  • 1
  • 1
  • 6

1 Answers1

1

As Aaron answered on the Q&A, when using Social.js, you should not use a callback URL. The code itself will watch the web view for what it needs.

Dawson Toth
  • 5,580
  • 2
  • 22
  • 37