Android Jtwitter,身份验证问题
您好,我在使用 JTwitter 功能对我的 Twitter 应用程序进行身份验证时遇到困难。我总是得到一个“TwitterException”
这是我的方法
OAuthSignpostClient oauthClient = new OAuthSignpostClient(consumerKey,
privateKey, "oob");
a)我不知道“oob”值应该是什么,它是“callbackURL”,在我的Twitter应用程序中它说“callBack URL:none”
所以我尝试将 "none"
、"None"
和 null
放在 "oob"
处> 没有不同的结果。
那么剩下的就是样板
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse(oauthClient.authorizeUrl().toString()));
startActivity(i);
// get the pin
String v = oauthClient.askUser("Please enter the verification PIN from Twitter");
oauthClient.setAuthorizationCode(v);
// Store the authorisation token details for future use
String[] accessToken = oauthClient.getAccessToken();
// Next time we can use new OAuthSignpostClient(OAUTH_KEY, OAUTH_SECRET,
// accessToken[0], accessToken[1]) to avoid authenticating again.
EditText twitterText = (EditText)findViewById(R.id.twitterText);
twitterText.getText();
// Make a Twitter object
Twitter twitter = new Twitter(null, oauthClient);
// Print Daniel Winterstein's status
//System.out.println(twitter.getStatus("winterstein"));
// Set my status
twitter.setStatus(twitterText.getText());
文件了,我只是不确定如何使这项工作起作用。希望我能更详细地说,但这与身份验证有关。我在网上看到的东西没有帮助
Hello I am having difficulty using the JTwitter functions to authenticate with my twitter application. I always get a "TwitterException"
Here is my method
OAuthSignpostClient oauthClient = new OAuthSignpostClient(consumerKey,
privateKey, "oob");
a) I don't know what the "oob" value SHOULD be, it is the "callbackURL" and in my application on twitter it says "callBack URL: none"
so I have tried putting "none"
, "None"
, and null
where "oob"
with no differing results.
then the rest is boilerplate
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse(oauthClient.authorizeUrl().toString()));
startActivity(i);
// get the pin
String v = oauthClient.askUser("Please enter the verification PIN from Twitter");
oauthClient.setAuthorizationCode(v);
// Store the authorisation token details for future use
String[] accessToken = oauthClient.getAccessToken();
// Next time we can use new OAuthSignpostClient(OAUTH_KEY, OAUTH_SECRET,
// accessToken[0], accessToken[1]) to avoid authenticating again.
EditText twitterText = (EditText)findViewById(R.id.twitterText);
twitterText.getText();
// Make a Twitter object
Twitter twitter = new Twitter(null, oauthClient);
// Print Daniel Winterstein's status
//System.out.println(twitter.getStatus("winterstein"));
// Set my status
twitter.setStatus(twitterText.getText());
at this point, I'm simply not sure on how to make this work. Wish I could be more verbose about it, but it has something to do with the authentication. Online things I've seen haven't been helpful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试作为您的回调网址:
记住!之后:
执行以下操作
覆盖< /em>
onResume()
获取验证码可以使用
uri.getQueryParameterNames()
获取参数String
名称。@BobVork
我想补充一点,您需要在 Twitter 应用程序(在 twitter.com 上)的“设置”选项卡中设置回调 URL。
您在该字段中输入的内容并不重要,但如果该字段为空,则回调 url 将不起作用。
Try this as your callback url:
Remember! After:
Do the following
override
onResume()
to get the verification codeYou can use
uri.getQueryParameterNames()
to get the parameterString
names.@BobVork
I'd just like to add that you'll need to have a callback URL set in the Settings tab for your Twitter app (on twitter.com).
It doesn't even matter what you put in the field, but if it's empty, callback urls will not work.
我不确定这就是问题所在,但似乎您从未设置 twitter 对象的用户名。
I'm not sure that's the problem, but it seems like you never set the user name for the twitter object.
好吧,我不知道 Jtwitter API 怎么样,而且我目前对 Java 的了解还不够,无法真正理解这段代码的内部工作原理,但是你尝试过,而不是
NULL
或None
,尝试使用?
。这是从 Javascript 进行调用时与 Restful API 一起使用的回调。尝试一下。Well, I don't know how it is with the Jtwitter API and I don't know enough Java at this point to really understand the inner workings of this code, but have you tried, instead of
NULL
orNone
, to try?
instead. That is the callback used with the restful API when making calls from Javascript. Try it out.