Package twitter4j

Examples of twitter4j.DirectMessage


            System.out.println("Usage: java twitter4j.examples.DirectMessage senderID senderPassword message recipientId");
            System.exit( -1);
        }
        Twitter twitter = new Twitter(args[0], args[1]);
        try {
            DirectMessage message = twitter.sendDirectMessage(args[2], args[3]);
            System.out.println("Direct message successfully sent to " +
                               message.getRecipientScreenName());
            System.exit(0);
        } catch (TwitterException te) {
            System.out.println("Failed to send message: " + te.getMessage());
            System.exit( -1);
        }
View Full Code Here


            JSONArray list = res.asJSONArray();
            int size = list.length();
            ResponseList<DirectMessage> directMessages = new ResponseListImpl<DirectMessage>(size, res);
            for (int i = 0; i < size; i++) {
                JSONObject json = list.getJSONObject(i);
                DirectMessage directMessage = new DirectMessageJSONImpl(json);
                directMessages.add(directMessage);
                if (conf.isJSONStoreEnabled()) {
                    DataObjectFactoryUtil.registerJSONObject(directMessage, json);
                }
            }
View Full Code Here

  public void sendReceiveMessages(String recipientId, String text)
  {
   
     // The factory instance is re-useable and thread safe.
      Twitter sender = new TwitterFactory().getInstance();
      DirectMessage message;
    try {
      message = sender.sendDirectMessage(recipientId, text);
      System.out.println("Sent: " + message.getText() + " to @" + message.getRecipientScreenName());
    } catch (TwitterException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
     
View Full Code Here

    try {
      // abbreviate the Tweet to meet the 140 character limit ...
      messageTxt = StringUtils.abbreviate(messageTxt, CHARACTER_LIMIT);
      // send the direct message
        DirectMessage message = client.sendDirectMessage(recipientId, messageTxt);
      logger.debug("Successfully sent direct message '{}' to @", message.getText(), message.getRecipientScreenName());
      return true;
    } catch (TwitterException e) {
      logger.error("Failed to send Tweet '" + messageTxt + "' because of: " + e.getLocalizedMessage());
      return false;
    }
View Full Code Here

            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);
View Full Code Here

            System.out.println("Usage: java twitter4j.examples.directmessage.SendDirectMessage [recipient screen name] [message]");
            System.exit(-1);
        }
        Twitter twitter = new TwitterFactory().getInstance();
        try {
            DirectMessage message = twitter.sendDirectMessage(args[0], args[1]);
            System.out.println("Direct message successfully sent to " + message.getRecipientScreenName());
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to send a direct message: " + te.getMessage());
            System.exit(-1);
View Full Code Here

TOP

Related Classes of twitter4j.DirectMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.