本文介绍了使用twitter4j Android的微博XAUTH例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安卓:我想对Android的份额如下XAUTH例如

Android: I am trying the following xAuth example for android share.

xAuth认证的微博分享Android中?

System.setProperty("twitter4j.oauth.consumerKey", "your token");
System.setProperty("twitter4j.oauth.consumerSecret", "your token secret");

Twitter twitter = new TwitterFactory().getInstance(login, password);

AccessToken accessToken = twitter.getOAuthAccessToken();
//Then you must save your Token and Token secret from AccesToken

if (mAccessToken != null) {
    if (mAccessToken.getToken() != null && mAccessToken.getTokenSecret() != null) {
        saveAccessToken(mAccessToken.getToken(), mAccessToken.getTokenSecret());
    }
}

我有IllegalStateException异常

I am having IllegalStateException

异常消息:java.lang.IllegalStateException:OAuth调用/秘密组合不提供

在下面的行

AccessToken accessToken = twitter.getOAuthAccessToken();

我所做的更改一些事情一样以下

I made changes some thing like following

Twitter twitter = new TwitterFactory().getInstance("login", "pass");
            twitter.setOAuthConsumer(getString(R.string.twtAPIKey), getString(R.string.twtSecret));
            AccessToken mAccessToken = twitter.getOAuthAccessToken();

和我再次得到了异常异常消息:java.lang.IllegalStateException:基本身份验证的情况下

and again I got exception Exception Msg: java.lang.IllegalStateException: Basic authenticated instance.

XAUTH的任何工作的例子?

Any working example of xAuth ?

推荐答案

我已经下使用


ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

     configurationBuilder.setOAuthConsumerKey(Consumer__Key);
     configurationBuilder.setOAuthConsumerSecret(Consumer_Secret);
     Configuration configuration = configurationBuilder.build();

     Twitter twitter = new TwitterFactory(configuration).getInstance("username","password"); 

     AccessToken token = twitter.getOAuthAccessToken();
     System.out.println("Access Token " +token );

     String name = token.getScreenName();
     System.out.println("Screen Name" +name);

     PrintWriter out= response.getWriter();
     System.out.println(token);

和使用的Andr​​oid应用程序中使用XAUTH成功登录到Twitter

And successfully login to Twitter using Android app using xauth

这篇关于使用twitter4j Android的微博XAUTH例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 16:48