0

Hello I have tried to post a tweet from my application. When I press on the button "post tweet" the authentication window (login window by twitter) opens, but when it is loaded my application just exits.

The following error occurs in the log;

[ERROR] Error Domain=com.google.GDataXML Code=-1 "The operation couldn’t be completed. (com.google.GDataXML error -1.)". in -[TiDOMDocumentProxy parseString:] (TiDOMDocumentProxy.m:50)

And in the end it says

 terminate called after throwing an instance of 'NSException

The code I used is:

var oAuthAdapter = new OAuthAdapter('SECRET KEY', 'KEY', 'HMAC-SHA1');


    // load the access token for the service (if previously saved)
    oAuthAdapter.loadAccessToken('twitter');

    oAuthAdapter.loadAccessToken('twitter');

    oAuthAdapter.send('https://api.twitter.com/1/statuses/update.json', [['status', 'Tweet from appcelerator ' + Math.random()]], 'Twitter', 'Published.', 'Not published.');

    if (oAuthAdapter.isAuthorized() == false) {
        // this function will be called as soon as the application is authorized 
        var receivePin = function(){
            // get the access token with the provided pin/oauth_verifier
            oAuthAdapter.getAccessToken('https://api.twitter.com/oauth/access_token');
            // save the 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);
    }
Tjekkles
  • 5,352
  • 8
  • 36
  • 53

2 Answers2

1

Found the answer.

The line

 oAuthAdapter.showAuthorizeUI('https://api.twitter.com/oauth/authorize'

Should be

 oAuthAdapter.showAuthorizeUI('https://api.twitter.com/oauth/authorize?'
Tjekkles
  • 5,352
  • 8
  • 36
  • 53
  • Welcome to SO! Great to hear it is sorted. You can accept your own answer by clicking the hollow checkmark next to the up/down arrows on this answer. When you have a chance, take an opportunity to read through the FAQ @ http://stackoverflow.com/faq. – Todd Main Mar 10 '11 at 23:32
0

Use This code instead of above two lines of showAuthorization and getRequestToken

oAuthAdapter.showAuthorizeUI('https://twitter.com/oauth/authorize?oauth_token=' +
oAuthAdapter.getRequestToken('https://twitter.com/oauth/request_token', 
[['oauth_callback', 'oob']]), receivePin, PinFinder.twitter);
Jens
  • 67,715
  • 15
  • 98
  • 113