package weibo4j.examples.account;
import weibo4j.User;
import weibo4j.Weibo;
import weibo4j.WeiboException;
/**
* @author hezhou
*
*/
public class VerifyCredentials {
/**
* @param args
*/
public static void main(String[] args) {
System.setProperty("weibo4j.oauth.consumerKey", Weibo.CONSUMER_KEY);
System.setProperty("weibo4j.oauth.consumerSecret", Weibo.CONSUMER_SECRET);
try {
User user = getWeibo(true,args).verifyCredentials();
System.out.println(user.toString());
} catch (WeiboException e) {
e.printStackTrace();
}
}
private static Weibo getWeibo(boolean isOauth,String[] args) {
Weibo weibo = new Weibo();
if(isOauth) {//oauth验证方式 args[0]:访问的token;args[1]:访问的密匙
weibo.setToken(args[0], args[1]);
}else {//用户登录方式
weibo.setUserId(args[0]);//用户名/ID
weibo.setPassword(args[1]);//密码
}
return weibo;
}
}