【问题标题】:How to logout Twitter - Twitter4J如何注销 Twitter - Twitter4J
【发布时间】:2012-08-03 01:18:20
【问题描述】:

我想退出 Twitter。我尝试使用新的请求 URI 清除引用和请求,但我的帐户仍然登录。我读了this question,但没有详细描述如何登录。如何注销 Twitter 并使用不同的帐户登录?你能给我一些注销或重新登录的代码吗?

函数获取请求URI

public static String getRequestURI() {
    try {
        final Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(Constant.CONSUMER_KEY, Constant.CONSUMER_SECRET);

        requestToken = twitter.getOAuthRequestToken(Constant.CALLBACK_URI);
        return requestToken.getAuthenticationURL();
    } catch (final TwitterException e) {
        e.printStackTrace();
    }
    return "";
}

函数清除参考

public static boolean logout(final Context context) {
    getPrefs(context);
    CustomSharedPreferences.setPreferences(Constant.ACCESS_TOKEN, "");
    CustomSharedPreferences.setPreferences(Constant.ACCESS_TOKEN_SECRET, "");
    return true;
}

【问题讨论】:

标签: android twitter4j


【解决方案1】:
mTwitter.setOAuthAccessToken(null);
mTwitter.shutdown();

这行得通,来源http://wenchaokong.blogspot.in/2013/03/android-twitter-integration-twitter4j.html

【讨论】:

    猜你喜欢
    • 2013-08-01
    • 2012-06-18
    • 1970-01-01
    • 2012-03-24
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    • 2010-12-29
    • 2013-05-10
    相关资源
    最近更新 更多