Log in to Twitter to see the latest. Join the conversation, follow accounts, see your Home Timeline, and catch up on Tweets from the people you know.
Publish & analyze Tweets, optimize ads, & create unique customer experiences with the Twitter API, Twitter Ads API, & Twitter Embeds. Tap into what’s happening to build what’s next Get immediate access to the Twitter API and unlock the potential of the Twitter data. Subscribe to Basic Find the right access for you Free. For write-only use cases and testing the Twitter API. Rate limited ...
You need to register your app for Twitter. You can only do that if you have your own private account. After you obtain , ConsumerKey, ConsumerSecret and AccessToken (they will be presented to you afret you register your application), the simplest solution is to change the code to the following example:AccessTokenSecret
public static void main(String[] args) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("yourConsumeKey")
.setOAuthConsumerSecret("yourConsumerSecret")
.setOAuthAccessToken("yourAccessToken")
.setOAuthAccessTokenSecret("yourTokenSecret");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
try {
Query query = new Query("query");
QueryResult result;
result = twitter.search(query);
List<Status> tweets = result.getTweets();
for (Status tweet : tweets) {
System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());
}
System.exit(0);
} catch (TwitterException te) {
te.printStackTrace();
System.out.println("Failed to search tweets: " + te.getMessage());
System.exit(-1);
}
}