Package twitter4j

Examples of twitter4j.QueryResult


  public void start(BundleContext context) throws Exception {
    Twitter twitter = new Twitter();
    Query query = new Query("from:theasf");
   
    try {
      QueryResult result = twitter.search(query);
        List<Tweet> tweets = result.getTweets();
        System.out.println("hits:" + tweets.size());
        for (Tweet tweet : result.getTweets()) {
            System.out.println(tweet.getFromUser() + ":" + StringEscapeUtils.unescapeXml(tweet.getText()));
        }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here


    public static void main(String... args) throws TwitterException{
        // The factory instance is re-useable and thread safe.
        Twitter twitter = new TwitterFactory().getInstance();
        Query query = new Query("#latino");
        query.setRpp(100);
        QueryResult result = twitter.search(query);
        System.out.println("hits:" + result.getResultsPerPage());
        System.out.println(result.getMaxId() + " :" + result.getPage());
        for (Tweet tweet : result.getTweets()) {           
            User user = twitter.showUser(tweet.getFromUser());
            System.out.println(user.getLocation());
            if (user.isGeoEnabled()) {
                GeoLocation geo = user.getStatus() != null ? user.getStatus().getGeoLocation() : null;
                System.out.println(geo + ":" + tweet.getLocation() + ":" + tweet.getFromUser() + ":" + tweet.getText());
View Full Code Here

                q.setSinceId(lastId);
                if (lastId == NOT_YET_SET)
                  q.setRpp(1);
                else
                  q.setRpp(20);
                QueryResult qr = twitter.search(q);
                List<Tweet> tweets = qr.getTweets();
                res = new MeasurementDataNumeric(req, (double) tweets.size());

                eventPoller.addTweets(tweets);
                if (tweets.size()>0)
                   lastId = tweets.get(0).getId();
View Full Code Here

      //older than or newer than?
      if (currentSearch.isFirstScan())
        query.setMaxId(currentSearch.getMaxID());
      else
        query.setSinceId(currentSearch.getSinceID());
      QueryResult result;
      try {
        result = twitter.search(query);
        int size = result.getTweets().size();
        logger.warning("-- Going to iterate on "+ size + " tweets");
        if (size==0) {
          logger.warning("-- REACHED "+ size + " tweets");
          return;
        }
        else if(size==1)
        {
          logger.warning("-- REACHED "+ size + " tweets");
          currentSearch.setFirstScan(false);
          pushSearch(currentSearch);
          return;
        }
        List<Status> tweets = result.getTweets();
        for (Status tweet : tweets) {
         
          System.out.println("@" + tweet.getUser().getScreenName()
              + " - " + tweet.getText());
          logger.warning("--  "+ tweet.getText());
View Full Code Here

        LOG.debug("Searching twitter with keywords: {}", keywords);
        return search(new Query(keywords));
    }

    private List<Tweet> search(Query query) throws TwitterException {
        QueryResult qr = te.getProperties().getTwitter().search(query);
        List<Tweet> tweets = qr.getTweets();

        if (te.getProperties().isFilterOld()) {
            for (Tweet t : tweets) {
                checkLastId(t.getId());
            }
View Full Code Here

            query.setSinceId(lastId);
        }

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

        for (Tweet t : list) {
            long newId = t.getId();
            if (newId > lastId) {
                lastId = newId;
View Full Code Here

        LOG.debug("Searching twitter with keywords: {}", keywords);
        return search(new Query(keywords));
    }

    private List<Tweet> search(Query query) throws TwitterException {
        QueryResult qr = te.getTwitter().search(query);
        List<Tweet> tweets = qr.getTweets();

        if (te.getProperties().isFilterOld()) {
            for (Tweet t : tweets) {
                checkLastId(t.getId());
            }
View Full Code Here

            query.setSinceId(lastId);
        }

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

        for (Tweet t : list) {
            long newId = t.getId();
            if (newId > lastId) {
                lastId = newId;
View Full Code Here

        }
       
        LOG.debug("Searching with {} pages.", numberOfPages);

        Twitter twitter = te.getProperties().getTwitter();
        QueryResult qr = twitter.search(query);
        List<Status> tweets = qr.getTweets();

        for (int i = 1; i < numberOfPages; i++) {
            if (!qr.hasNext()) {
                break;
            }

            qr = twitter.search(qr.nextQuery());
            tweets.addAll(qr.getTweets());
        }

        if (te.getProperties().isFilterOld()) {
            for (Status t : tweets) {
                checkLastId(t.getId());
View Full Code Here

            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) {
                long newId = t.getId();
View Full Code Here

TOP

Related Classes of twitter4j.QueryResult

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.