Example usage for twitter4j Twitter showDirectMessage

List of usage examples for twitter4j Twitter showDirectMessage

Introduction

In this page you can find the example usage for twitter4j Twitter showDirectMessage.

Prototype

DirectMessage showDirectMessage(long id) throws TwitterException;

Source Link

Document

Returns a single Direct Message event by the given id.

Usage

From source file:com.ikungolf.java.javatwitter.directmessage.ShowDirectMessage.java

License:Apache License

/**
 * Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]
 *
 * @param args String[]/*from  w  ww .  ja v  a  2  s.c  o m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]");
        System.exit(-1);
    }
    Twitter twitter = new TwitterFactory().getInstance();
    try {
        DirectMessage message = twitter.showDirectMessage(Long.parseLong(args[0]));
        System.out.println("From: @" + message.getSenderScreenName() + " id:" + message.getId() + " - "
                + message.getText());
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get message: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.directmessage.ShowDirectMessage.java

License:Apache License

/**
 * Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]
 *
 * @param args String[]/*from   ww  w . j av  a 2  s.c o m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.directmessage.ShowDirectMessage [message id]");
        System.exit(-1);
    }
    Twitter twitter = new TwitterFactory().getInstance();
    try {
        DirectMessage message = twitter.showDirectMessage(Long.parseLong(args[0]));
        System.out.println("From: id:" + message.getId() + " - " + message.getText());
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get message: " + te.getMessage());
        System.exit(-1);
    }
}