コード例 #1
0
  /**
   * It returns MAX(available_tweets,200,limit) tweets from the search of the specified query. In
   * case of error, returns null.
   */
  public QueryResult searchTweets(String queryTerm, int limit) {

    try {
      Query query = new Query(queryTerm);
      query.setCount(limit);
      QueryResult result = twitter.search(query);
      LoggerClass.log(
          Level.INFO,
          "OK. Searching tweets for term "
              + queryTerm
              + " and limit "
              + limit
              + ". "
              + result.getCount()
              + " results.");
      return result;
    } catch (Exception ex) {
      LoggerClass.log(
          Level.SEVERE,
          "ERROR searching tweets for term " + queryTerm + " and limit " + limit + ".");
      System.err.println("[ERROR] Can't search tweets");
      ex.printStackTrace();
      return null;
    }
  }
コード例 #2
0
 public TwitterHandler() {
   twitter = TwitterFactory.getSingleton();
   LoggerClass.log(Level.INFO, "OK. Twitter Handler initialized");
 }