0

您好,我试图从我的应用程序中发布一条推文。当我按下“发布推文”按钮时,身份验证窗口(twitter 的登录窗口)打开,但是当它被加载时,我的应用程序就退出了。

日志中出现以下错误;

[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)

最后它说

 terminate called after throwing an instance of 'NSException

我使用的代码是:

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);
    }
4

2 回答 2

1

找到了答案。

线

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

应该

 oAuthAdapter.showAuthorizeUI('https://api.twitter.com/oauth/authorize?'
于 2011-03-10T14:17:06.823 回答
0

使用此代码代替上面两行 showAuthorization 和 getRequestToken

oAuthAdapter.showAuthorizeUI('https://twitter.com/oauth/authorize?oauth_token=' +
oAuthAdapter.getRequestToken('https://twitter.com/oauth/request_token', 
[['oauth_callback', 'oob']]), receivePin, PinFinder.twitter);
于 2014-06-27T06:18:57.380 回答