新浪微博授权

这两天研究新浪微博那个坑爹货..网上各种假代码..让我纠结了很久`最后在朋友帮助下终于弄出来了



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:为注册的回调地址

你可能感兴趣的:(新浪微博)