如何使用twitter登录我的Codename one应用程序

我试图在我的Codename一个应用程序中使用twitter登录,但是当我点击登录按钮时它会重定向到twitter,但不会要求凭据,它只会抛出以下错误:

哇那里! 此页面没有请求令牌。 这是我们要求使用您的Twitter帐户的应用程序所需的特殊密钥。 请返回发送给您的网站或应用程序,然后重试; 这可能只是一个错误。

下面是我的代码:

twitter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Oauth2 Tauth = new Oauth2("https://api.twitter.com/oauth/authenticate?oauth_token", "XXXXXXXXXXXXXXXXXX", "https://www.codenameone.com"); Tauth.showAuthentication(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { AccessToken token = (AccessToken) evt.getSource(); Log.p(token.toString()); } }); } }); 

所以任何人都知道这段代码有什么问题吗?

我自己没有使用过twitter的API,但是你的url看起来不正确。 此文档页面表明您应该使用“ https://api.twitter.com/oauth2/token ”。

并且不要将查询字符串包含在URL中。 只是基本url“ https://api.twitter.com/oauth2/token ”。

Oauth2类将添加必要的查询参数。