【问题标题】:Twitter integration using oAuth errorTwitter 集成使用 oAuth 错误
【发布时间】:2011-07-12 17:41:24
【问题描述】:

你好 我试图从我的应用程序中发布一条推文。当我按下“发布推文”按钮时,身份验证窗口(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);
    }

【问题讨论】:

    标签: twitter oauth integration titanium nsexception


    【解决方案1】:

    找到答案了。

    线

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

    应该是

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

    【讨论】:

    • 欢迎来到 SO!很高兴听到它已排序。您可以通过单击此答案上/下箭头旁边的空心复选标记来接受您自己的答案。如果有机会,请借此机会阅读常见问题解答@@stackoverflow.com/faq
    【解决方案2】:

    用这段代码代替上面两行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);
    

    【讨论】:

      猜你喜欢
      • 2011-04-12
      • 2014-12-02
      • 2013-07-04
      • 2017-04-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多