簡體   English   中英

如何從Android中的Twitter獲取Access_Token?

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

我有一些代碼及其登錄或注銷的工作,但我想獲取access_tonken並將其存儲在數據庫中。

我的代碼:

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

如何獲得access_token? 任何解決方案?

訪問令牌返回到您的“ callbackUrl”,並且會話時間很短。 您不能將其存儲在數據庫中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM