/** * Usage: java twitter4j.examples.trends.GetAvailableTrends [latitude longitude] * * @param args message */ public static void main(String[] args) { try { Twitter twitter = new TwitterFactory().getInstance(); ResponseList<Location> locations; if (args.length >= 2) { locations = twitter.getAvailableTrends( new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1]))); } else { locations = twitter.getAvailableTrends(); } System.out.println("Showing available trends"); for (Location location : locations) { System.out.println(location.getName() + " (woeid:" + location.getWoeid() + ")"); } System.out.println("done."); System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to get trends: " + te.getMessage()); System.exit(-1); } }
public static void main(String[] args) throws Exception { Context context = new Context("conf/producer.conf"); Tweety tp = new Tweety(); try { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://172.20.95.137/mongo_test?" + "user=manoj&password=qwerty1!"; Connection conn = DriverManager.getConnection(url); System.out.println(url); Statement stmt = conn.createStatement(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setOAuthConsumerKey("ujS6V0corQ4v8K4dp6bIlVYsq"); cb.setOAuthConsumerSecret("XhmTLcS4BI6zy9fZ0xIOy1ZZkAnQYZ1jFrlHojWuWpx2RCWH9H"); cb.setOAuthAccessToken("30427118-YNLB3WfviD4j7MvNgU4gZ7SPQbCDBXWh4kPZcHXrY"); cb.setOAuthAccessTokenSecret("LkhcZUJbj33RBc1DTXrxJps4ELgog8WxoRS6gCReemOHc"); cb.setJSONStoreEnabled(true); cb.setIncludeEntitiesEnabled(true); cb.setHttpProxyHost("proxy.tcs.com"); cb.setHttpProxyPort(8080); cb.setHttpProxyUser("467098"); cb.setHttpProxyPassword("See@0615"); Twitter twitter = new TwitterFactory(cb.build()).getInstance(); ResponseList<Location> locations; locations = twitter.getAvailableTrends(); System.out.println("Showing available trends"); Trends trends = twitter.getPlaceTrends(2295386); stmt.executeUpdate("drop table hashtag"); stmt.executeUpdate("create table hashtag(name varchar(50),count int)"); for (int i = 0; i <= 5; i++) { System.out.println(trends.getTrends()[i].getName()); hashtags[i] = trends.getTrends()[i].getName(); stmt.executeUpdate("insert into hashtag values (\'" + hashtags[i] + "\'" + "," + 0 + ")"); } System.out.println("done."); } catch (Exception te) { te.printStackTrace(); System.out.println("Failed to get trends: " + te.getMessage()); System.exit(-1); } tp.start(context); }