Example usage for twitter4j Status getUser

List of usage examples for twitter4j Status getUser

Introduction

In this page you can find the example usage for twitter4j Status getUser.

Prototype

User getUser();

Source Link

Document

Return the user associated with the status.
This can be null if the instance is from User.getStatus().

Usage

From source file:examencodtwitter.Metodos.java

/**
         //from  w ww .j  a va 2  s .  com
 *
 * @throws TwitterException
 */
public void verTimeLine() throws TwitterException {

    List<Status> statuses = twitter.getHomeTimeline();
    System.out.println("Mostrando su Timeline.");
    for (Status status : statuses) {
        System.out.println(status.getUser().getName() + ":" + status.getText());
    }
}

From source file:examencodtwitter.Metodos.java

/**
         /*  w w  w .  j  a  v  a 2  s. c  o m*/
 *
 * @param busqueda
 * @throws TwitterException
 */
public void buscar(String busqueda) throws TwitterException {

    Query query = new Query(busqueda);
    QueryResult result = twitter.search(query);
    for (Status status : result.getTweets()) {
        System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());
    }
}

From source file:examendetwitter.metodostwitter.java

/**
 * Nos da nuestro timeLine/* w ww. ja va2s  .c o  m*/
 */
public void verTL() throws TwitterException {

    List<Status> statuses = twitter.getHomeTimeline();
    System.out.println("Showing home timeline.");
    for (Status status : statuses) {
        System.out.println(status.getUser().getName() + ":" + status.getText());
    }

}

From source file:examendetwitter.metodostwitter.java

/**
 * Busca tweets con el texto introducido
 *///from  w w w. j a  v  a 2s .  c  o  m
public void buscarTrending(String busqueda) throws TwitterException {

    Query query = new Query(busqueda);
    QueryResult result = twitter.search(query);
    for (Status status : result.getTweets()) {
        System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());
    }

}

From source file:examentwittercod.MetodosTwitter.java

/**
 * Nos da nuestro timeLine//from  ww w. ja v  a  2  s. c om
 */
public void verTL() throws TwitterException {

    List<Status> statuses = twitter.getHomeTimeline();
    System.out.println("Mostrando Linea del Tiempo.");
    for (Status status : statuses) {
        System.out.println(status.getUser().getName() + ":" + status.getText());
    }

}

From source file:examples.GetUserListStatuses.java

License:Apache License

/**
 * Usage: java twitter4j.examples.list.GetUserListStatuses [list id]
 *
 * @param args message/*from w w w. j  a va  2 s .c o  m*/
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.list.GetUserListStatuses [list id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Paging page = new Paging(1);
        ResponseList<Status> statuses;
        do {
            statuses = twitter.getUserListStatuses(Integer.parseInt(args[0]), page);
            for (Status status : statuses) {
                System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
            }
            page.setPage(page.getPage() + 1);
        } while (statuses.size() > 0 && page.getPage() <= 10);
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to list statuses: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:ezbake.training.TweetIngestParser.java

License:Apache License

private Tweet convertToTweet(Status status) {
    Tweet tweet = new Tweet();
    tweet.setTimestamp(status.getCreatedAt().getTime());
    tweet.setId(status.getId());//from  w w w .  j a  v a 2  s .c  om
    tweet.setText(status.getText());
    tweet.setUserId(status.getUser().getId());
    tweet.setUserName(status.getUser().getName());
    tweet.setIsFavorite(status.isFavorited());
    tweet.setIsRetweet(status.isRetweet());
    if (status.getGeoLocation() != null) {
        tweet.setGeoLocation(
                new Coordinate(status.getGeoLocation().getLatitude(), status.getGeoLocation().getLongitude()));
    }
    return tweet;
}

From source file:flight_ranker.Flight_colllector.java

public static void main(String[] args) throws FileNotFoundException, IOException {

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true);// w w  w .  java2  s  .  c  om
    cb.setOAuthConsumerKey("Oa6WAzH0j3sgVrP0CNGvxnWA2");
    cb.setOAuthConsumerSecret("sLdoFybvJvVFz7Lxbbv9KWQDFeKcVeZAkWDC4QMHnx5lV2OmGE");
    cb.setOAuthAccessToken("2691889945-5NOBWKUgT9FiAoyOQSCFg8CLlPRlDMbWcUrJBdK");
    cb.setOAuthAccessTokenSecret("J6tA8Sxrtz2JNSFdQwAonbGxNfLNuD9I54Zfvomku3p5t");

    TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();

    StatusListener listener = new StatusListener() {

        @Override
        public void onException(Exception arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onScrubGeo(long arg0, long arg1) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStatus(Status status) {
            User user = status.getUser();

            // gets Username
            String username = status.getUser().getScreenName();
            long followers = user.getFollowersCount();

            long retweets = status.getRetweetCount();

            long favs = status.getFavoriteCount();

            System.out.println("USERNAME--> " + username);
            System.out.println("FOLLOWERS--> " + followers);
            String profileLocation = user.getLocation();

            //                System.out.println("RETWEETS--> "+retweets);

            //                System.out.println("FAVOURITES--> "+favs);

            System.out.println("LOCATION--> " + profileLocation);
            long tweetId = status.getId();
            System.out.println("TWEET ID--> " + tweetId);
            String content = status.getText();
            System.out.println("TWEET--> " + content + "\n");

            BufferedWriter b1 = null, b2, b3, b4, b5, b6, b7 = null;

            try {
                //output_file = new BufferedReader(new FileReader("G:\\Sentiwords.txt"));

                FileWriter f1 = new FileWriter("G:\\flights_data.txt", true);
                b1 = new BufferedWriter(f1);
                b1.write("#USERNAME- " + username);
                b1.newLine();

                b1.write("#Followers- " + followers);

                b1.newLine();

                b1.write("#Location- " + profileLocation);

                b1.newLine();
                b1.write("#ID- " + tweetId);

                b1.newLine();
                b1.write("#Tweet- " + content);
                b1.newLine();
                b1.newLine();

                tweet_editor modified_tweet = new tweet_editor(content);
                //tweet_tagger tagged_tweet = new tweet_tagger(modified_tweet.edited_tweet);
                //System.out.println(tagged_tweet.tagged);

                sentiment_calculator senti_value = new sentiment_calculator(modified_tweet.edited_tweet);

                if (content.contains("Indigo")) {
                    System.out.println("indigo");
                    FileWriter f2 = new FileWriter("G:\\Indigo.txt", true);
                    b2 = new BufferedWriter(f2);
                    b2.write(Double.toString(senti_value.senti_rate));
                    b2.newLine();
                }

                if (content.contains("Jet")) {
                    System.out.println("jet");
                    FileWriter f3 = new FileWriter("G:\\jet.txt", true);
                    b3 = new BufferedWriter(f3);
                    b3.write(Double.toString(senti_value.senti_rate));
                    b3.newLine();
                }

                if (content.contains("Indian")) {
                    System.out.println("indian");
                    FileWriter f4 = new FileWriter("G:\\Indian.txt", true);
                    b4 = new BufferedWriter(f4);
                    b4.write(Double.toString(senti_value.senti_rate));
                    b4.newLine();
                }

                if (content.contains("Spicejet")) {
                    System.out.println("spicejet");
                    FileWriter f5 = new FileWriter("G:\\spicejet.txt", true);
                    b5 = new BufferedWriter(f5);
                    b5.write(Double.toString(senti_value.senti_rate));
                    b5.newLine();
                }

                if (content.contains("AirAsia")) {
                    System.out.println("airasia");
                    FileWriter f6 = new FileWriter("G:\\airasia.txt", true);
                    b6 = new BufferedWriter(f6);
                    b6.write(Double.toString(senti_value.senti_rate));
                    b6.newLine();
                }

                try {
                    //output_file = new BufferedReader(new FileReader("G:\\Sentiwords.txt"));

                    FileWriter f7 = new FileWriter("G:\\flight_senti.txt", true);
                    b7 = new BufferedWriter(f7);
                    b7.write(String.valueOf(senti_value.senti_rate));
                    b7.newLine();

                }

                catch (IOException e) {
                    e.printStackTrace();
                }

                finally {
                    try {
                        b7.close();
                    } catch (IOException ex) {
                        Logger.getLogger(Flight_colllector.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }

            }

            catch (IOException e) {
                e.printStackTrace();
            }

            finally {
                try {
                    b1.close();
                } catch (IOException ex) {
                    Logger.getLogger(Flight_colllector.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

        @Override
        public void onTrackLimitationNotice(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onStallWarning(StallWarning sw) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    };

    FilterQuery fq = new FilterQuery();

    String keywords[] = {
            "Indian Airlines, Indigo Airlines, Indigo Airline , Indian Airline , Spicejet , jetAirways , Jet Airways, Jet Airlines , airasia" }; //we will pass stock related keyword here

    fq.track(keywords);

    twitterStream.addListener(listener);
    twitterStream.filter(fq);

}

From source file:fr.ybonnel.model.TweetPhoto.java

License:Apache License

public static Stream<TweetPhoto> fromStatus(Status status) {
    String user = status.getUser().getScreenName();
    String avatar = status.getUser().getBiggerProfileImageURL();
    String text = status.getText();
    /*if (status.getMediaEntities().length == 0) {
    return Stream.of(new TweetPhoto(user, avatar, "http://placehold.it/400x300", text));
    }*//*from  www.j ava 2  s. c  o  m*/
    return Arrays.stream(status.getMediaEntities())
            .map(media -> new TweetPhoto(user, avatar, media.getMediaURL(), text));
}

From source file:fr.ybonnel.modele.TweetPhoto.java

License:Apache License

public static Stream<TweetPhoto> fromStatus(Status status) {
    String user = status.getUser().getScreenName();
    String avatar = status.getUser().getBiggerProfileImageURL();
    String text = status.getText();
    return Arrays.stream(status.getMediaEntities()).map(MediaEntity::getMediaURL)
            .map(url -> new TweetPhoto(user, avatar, url, text));
}