Example #1
0
  private void syncSearches(TwitterHelper th, TweetDB tdb) {
    List<SavedSearch> searches = th.getSavedSearchesFromServer();
    List<SavedSearch> storedSearches = th.getSavedSearchesFromDb();

    for (SavedSearch search : searches) {
      if (!storedSearches.contains(search)) {
        th.persistSavedSearch(search);
      }
    }

    for (SavedSearch search : storedSearches) {
      if (!searches.contains(search)) {
        tdb.deleteSearch(search.getId());
      }
    }
  }
Example #2
0
 /**
  * Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]
  *
  * @param args message
  */
 public static void main(String[] args) {
   if (args.length < 1) {
     System.out.println(
         "Usage: java twitter4j.examples.savedsearches.DestroySavedSearch [saved search id]");
     System.exit(-1);
   }
   try {
     Twitter twitter = new TwitterFactory().getInstance();
     SavedSearch savedSearch = twitter.destroySavedSearch(Integer.parseInt(args[0]));
     System.out.println(
         "Successfully deleted saved search [name:"
             + savedSearch.getName()
             + " query:"
             + savedSearch.getQuery()
             + " id:"
             + savedSearch.getId()
             + "]");
     System.exit(0);
   } catch (TwitterException te) {
     te.printStackTrace();
     System.out.println("Failed to delete the saved search: " + te.getMessage());
     System.exit(-1);
   }
 }