"Usage: java weibo4j.examples.Update ID Password text");
System.exit( -1);
}
long l1 = System.currentTimeMillis();
Weibo weibo = new Weibo(args[0], args[1]);
// System.out.println(weibo.getRateLimitStatus());
List<Status> statuses = weibo.getPublicTimeline();
for (Status status : statuses) {
System.out.println(status);
}
String msg = args[2] + new java.util.Date();
// normal status
Status status = weibo.updateStatus(args[2] + System.currentTimeMillis());
// status with geocode
try {
status = weibo.updateStatus(msg, 40.7579, -73.985);
} catch (JSONException e1) {
e1.printStackTrace();
}
long l2 = System.currentTimeMillis();
System.out.println("Successfully updated the status to [" + status.getText() + "].");
System.out.println("Time elapsed: " + (l2 - l1));
try {
Thread.sleep(1000); // avoid flush server
} catch (InterruptedException e) {
e.printStackTrace();
}
// add a comment for the status
long sid = status.getId();
Comment cmt = weibo.updateComment("评论1 " + new java.util.Date(), String.valueOf(sid), null);
weibo.getComments(String.valueOf(sid));
weibo.updateComment("评论2 " + new java.util.Date(), String.valueOf(sid), null);
try {
Thread.sleep(1000); // avoid flush server
} catch (InterruptedException e) {
e.printStackTrace();
}
Comment cmt2 = weibo.destroyComment(cmt.getId());
System.out.println("delete " + cmt2);
}