使用 oAuth 错误集成 Twitter
你好 我尝试从我的应用程序中发布一条推文。当我按下“发布推文”按钮时,身份验证窗口(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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到了答案。
该行
应该是
Found the answer.
The line
Should be
使用此代码代替上面两行 showAuthorization 和 getRequestToken
Use This code instead of above two lines of showAuthorization and getRequestToken