use of twitter4j.DirectMessageList in project twitter4j by yusuke.
the class GetDirectMessages method main.
/**
* Usage: java twitter4j.examples.directmessage.GetDirectMessages
*
* @param args String[]
*/
public static void main(String[] args) {
Twitter twitter = new TwitterFactory().getInstance();
try {
String cursor = null;
int count = 20;
DirectMessageList messages;
do {
System.out.println("* cursor:" + cursor);
messages = cursor == null ? twitter.getDirectMessages(count) : twitter.getDirectMessages(count, cursor);
for (DirectMessage message : messages) {
System.out.println("From: " + message.getSenderId() + " id:" + message.getId() + " [" + message.getCreatedAt() + "]" + " - " + message.getText());
System.out.println("raw[" + message + "]");
}
cursor = messages.getNextCursor();
} while (messages.size() > 0 && cursor != null);
System.out.println("done.");
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to get messages: " + te.getMessage());
System.exit(-1);
}
}
Aggregations