Last active
December 9, 2020 14:34
-
-
Save milindjagre/96ff54bf5781533b2762ca3239b7d107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.milind.twitter.trends; | |
import java.io.IOException; | |
import twitter4j.Trend; | |
import twitter4j.Trends; | |
import twitter4j.Twitter; | |
import twitter4j.TwitterException; | |
import twitter4j.TwitterFactory; | |
import twitter4j.conf.ConfigurationBuilder; | |
/** | |
* | |
* @author Milind | |
*/ | |
public class TwitterTrendingTopics { | |
public static void main(String[] args) throws IOException, TwitterException { | |
ConfigurationBuilder cb = new ConfigurationBuilder(); | |
cb.setDebugEnabled(true) | |
.setOAuthConsumerKey("3jmA1BqasLHfItBXj3KnAIGFB") | |
.setOAuthConsumerSecret("imyEeVTctFZuK62QHmL1I0AUAMudg5HKJDfkx0oR7oFbFinbvA") | |
.setOAuthAccessToken("265857263-pF1DRxgIcxUbxEEFtLwLODPzD3aMl6d4zOKlMnme") | |
.setOAuthAccessTokenSecret("uUFoOOGeNJfOYD3atlcmPtaxxniXxQzAU4ESJLopA1lbC"); | |
TwitterFactory tf = new TwitterFactory(cb.build()); | |
Twitter twitter = tf.getInstance(); | |
Trends trends = twitter.getPlaceTrends(1); | |
int count = 0; | |
for (Trend trend : trends.getTrends()) { | |
if (count < 10) { | |
System.out.println(trend.getName()); | |
count++; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file gives you the top 10 worldwide trending topics on twitter