开发者

xAuth Authentication for Twitter Share in Android?

I am working on the Twitter Authentication. The Basic Authentication will expire on August 16th onwards. So we have to use OAuth to use Twitter Authentication. But Its some Complica开发者_如何学JAVAted to implement. XAuth is cuts off the two steps. But the Problem is i used Twitter4j to authenticate.And also had bad documentation too. I want to use XAuth from 1.6 itself. Which package you suggest to use. and If any example or tutorial for specifiacally for Android to use XAuth Authentication.


EDIT: In my code I did this:

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

When you want to use your Token you just do this:

TwitterFactory factory = new TwitterFactory();
Twitter twitter = factory.getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
AccessToken accessToken = loadAccessToken();
twitter.setOAuthAccessToken(accessToken);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜