Package twitter4j

Examples of twitter4j.Twitter$Device


        Integer numberOfPages = exchange.getIn().getHeader(TwitterConstants.TWITTER_NUMBER_OF_PAGES, Integer.class);
        if (numberOfPages == null) {
            numberOfPages = te.getProperties().getNumberOfPages();
        }

        Twitter twitter = te.getProperties().getTwitter();
        log.debug("Searching twitter with keywords: {}", keywords);
        QueryResult results = twitter.search(query);
        List<Status> list = results.getTweets();

        for (int i = 1; i < numberOfPages; i++) {
            if (!results.hasNext()) {
                break;
            }
            log.debug("Fetching page");
            results = twitter.search(results.nextQuery());
            list.addAll(results.getTweets());
        }

        if (te.getProperties().isFilterOld()) {
            for (Status t : list) {
View Full Code Here


            System.out.println("No TwitterID/Password specified.");
            System.out.println(
                "Usage: java twitter4j.examples.GetDirectMessages ID Password");
            System.exit( -1);
        }
        Twitter twitter = new Twitter(args[0], args[1]);
        try {
            List<DirectMessage> messages = twitter.getDirectMessages();
            for (DirectMessage message : messages) {
                System.out.println("Sender:" + message.getSenderScreenName());
                System.out.println("Text:" + message.getText() + "\n");
            }
            System.exit(0);
View Full Code Here

     * Usage: java -Dtwitter4j.oauth.consumerKey=[consumer key] -Dtwitter4j.oauth.consumerSecret=[consumer secret] twitter4j.examples.OAuthUpdate [message]
     * @param args message
     */
    public static void main(String[] args) {
        try {
            Twitter twitter = new Twitter();
            RequestToken requestToken = twitter.getOAuthRequestToken();
            System.out.println("Got request token.");
            System.out.println("Request token: "+ requestToken.getToken());
            System.out.println("Request token secret: "+ requestToken.getTokenSecret());
            AccessToken accessToken = null;

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while (null == accessToken) {
                System.out.println("Open the following URL and grant access to your account:");
                System.out.println(requestToken.getAuthorizationURL());
                System.out.print("Hit enter when it's done.[Enter]:");
                br.readLine();
                try{
                    accessToken = requestToken.getAccessToken();
                } catch (TwitterException te) {
                    if(401 == te.getStatusCode()){
                        System.out.println("Unable to get the access token.");
                    }else{
                        te.printStackTrace();
                    }
                }
            }
            System.out.println("Got access token.");
            System.out.println("Access token: "+ accessToken.getToken());
            System.out.println("Access token secret: "+ accessToken.getTokenSecret());

            Status status = twitter.updateStatus(args[0]);
            System.out.println("Successfully updated the status to [" + status.getText() + "].");
            System.exit(0);
        } catch (TwitterException te) {
            System.out.println("Failed to get timeline: " + te.getMessage());
            System.exit( -1);
View Full Code Here

            prop.load(new FileInputStream(fileName));
        } catch (IOException ex) {
            log.error("Configuration file not found:" + ex.getMessage());
            System.exit( -1);
        }
        this.twitter = new Twitter(prop.getProperty("id"),
                                   prop.getProperty("password"));
        this.feedurl = prop.getProperty("feedurl");
        this.lastUpdate = new Date(Long.valueOf(prop.getProperty("lastUpdate",
            "0")));
    }
View Full Code Here

        if (args.length < 3) {
            System.out.println(
                "Usage: java twitter4j.examples.Update ID Password text");
            System.exit( -1);
        }
        Twitter twitter = new Twitter(args[0], args[1]);
        Status status = twitter.updateStatus(args[2]);
        System.out.println("Successfully updated the status to [" + status.getText() + "].");
    }
View Full Code Here

     * Usage: java twitter4j.examples.GetTimelines ID Password
     * @param args String[]
     */
    public static void main(String[] args) {

        Twitter unauthenticatedTwitter = new Twitter();
        System.out.println("Showing public timeline.");
        try {
            List<Status> statuses = unauthenticatedTwitter.getPublicTimeline();
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
            }
            if (args.length < 2) {
                System.out.println(
                    "You need to specify TwitterID/Password combination to show UserTimelines.");
                System.out.println(
                    "Usage: java twitter4j.examples.GetTimelines ID Password");
                System.exit(0);
            }

            // Other methods require authentication
            Twitter twitter = new Twitter(args[0], args[1]);
            statuses = twitter.getFriendsTimeline();
            System.out.println("------------------------------");
            System.out.println("Showing " + args[0] + "'s friends timeline.");
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
            }
            statuses = twitter.getUserTimeline();
            System.out.println("------------------------------");
            System.out.println("Showing " + args[0] + "'s timeline.");
            for (Status status : statuses) {
                System.out.println(status.getUser().getName() + ":" +
                                   status.getText());
            }
            Status status = twitter.show(81642112l);
            System.out.println("------------------------------");
            System.out.println("Showing " + status.getUser().getName() +
                               "'s status updated at " + status.getCreatedAt());
            System.out.println(status.getText());
            System.exit(0);
View Full Code Here

        if (args.length < 4) {
            System.out.println("No TwitterID/Password specified.");
            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());
View Full Code Here

  public void execute(DelegateExecution execution) throws Exception {     
    String content = (String) execution.getVariable("content");
     
    AccessToken accessToken = new AccessToken("220324559-8hWDVUXMSOaAnmtNNwBuNuhGJ6hOGwNdWHqhdOsU", "sGBZafB7saWYMwnPQGjjwU9Ggr0IJYkmPdyAFU5PI");
    Twitter twitter = new TwitterFactory().getOAuthAuthorizedInstance("HW62M0Rxtt39CbgdgP1og", "TJHNqolmPD6aHPtX8ec5Xp5zgIJcsMBTkwMpGCqdGuk", accessToken);
    twitter.updateStatus(content);
  }
View Full Code Here

   * @throws Exception
   */
  private void post(String twitterUrl, String twitterUsername,
      String twitterPassword, String msg) throws Exception {
    System.out.println("Posting to Twitter: " + msg);
    Twitter twitter = new Twitter(twitterUsername, twitterPassword, twitterUrl);
    twitter.updateStatus(msg);
  }
View Full Code Here

    public Collection<MyTweet> createReal() {
        List<MyTweet> tweets = new ArrayList<MyTweet>();
        try {
            // get some tweets about java
            Twitter twitter4j = new TwitterFactory().getInstance();
            for (int i = 0; i < 3; i++) {
                Query q = new Query("java");
                q.setRpp(100);
                for (Tweet tw : twitter4j.search(q).getTweets()) {
                    MyTweet myTw = new MyTweet(tw.getId(), tw.getFromUser());
                    myTw.setText(tw.getText());
                    myTw.setCreatedAt(tw.getCreatedAt());
                    myTw.setFromUserId(tw.getFromUserId());
                    tweets.add(myTw);
View Full Code Here

TOP

Related Classes of twitter4j.Twitter$Device

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.