天天看點

新浪微網誌授權

這兩天研究新浪微網誌那個坑爹貨..網上各種假代碼..讓我糾結了很久`最後在朋友幫助下終于弄出來了

Weibo weibo=Weibo.getInstance(KEY, URL); weibo.authorize(this, new WeiboAuthListener() { public void onComplete(Bundle value) { String token = value.getString("access_token"); String expires_in = value.getString("expires_in"); Oauth2AccessToken oauth2AccessToken = new Oauth2AccessToken(token,expires_in); if(oauth2AccessToken.isSessionValid()){ String date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date(oauth2AccessToken.getExpiresTime())); Toast.makeText(getApplicationContext(),"授權成功", Toast.LENGTH_SHORT).show(); } }

KEY:為注冊的微網誌key

URL:為注冊的回調位址

繼續閱讀