マイクロブログを送信
3032 ワード
package weibo4j.examples;
import weibo4j.Status;
import weibo4j.Weibo;
public class UpdateStatus {
/**
*
* @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 {
Weibo weibo = getWeibo(true,args);
Status status = weibo.updateStatus(" ");
System.out.println(status.getId() + " : "+ status.getText()+" "+status.getCreatedAt());
} catch (Exception 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;
}
}