简体   繁体   English

如何从Android中的Twitter获取Access_Token?

[英]How to get Access_Token from twitter in android?

I have some code and its work to login or logout ,but I want to get access_tonken and store it in database. 我有一些代码及其登录或注销的工作,但我想获取access_tonken并将其存储在数据库中。

my code: 我的代码:

private void onTwitterClick() {

    if (mTwitter.hasAccessToken()) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);

        builder.setMessage("Delete current Twitter connection?").setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                mTwitter.resetAccessToken();
                mTwitterBtn.setChecked(false);
                mTwitterBtn.setText("  Twitter (Not connected)");
                mTwitterBtn.setTextColor(Color.GRAY);
            }
        })
        .setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();

                mTwitterBtn.setChecked(true);
            }
        });
        final AlertDialog alert = builder.create();
        alert.show();
    } else {
        mTwitterBtn.setChecked(false);
        mTwitter.authorize();   
        // mTwitter.processToken(callbackUrl);        
    }
}

How to get access_token ?? 如何获得access_token? any solution?? 任何解决方案?

The access token return to your "callbackUrl" and lives short period of session time. 访问令牌返回到您的“ callbackUrl”,并且会话时间很短。 You can not store it in your database. 您不能将其存储在数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM