2011-03-10 96 views
0

你好 我试图从我的应用程序发布推文。当我按下按钮“发布推文”时,身份验证窗口(通过twitter登录窗口)会打开,但当它加载时,我的应用程序就会退出。使用oAuth错误的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); 
    } 

回答

1

找到了答案。

线

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

应该

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

欢迎SO!很高兴听到它被排序。您可以通过点击此答案上的向上/向下箭头旁边的空白复选标记来接受您自己的答案。当您有机会时,请抓住机会阅读FAQ @ http://stackoverflow.com/faq。 – 2011-03-10 23:32:30

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