It is so simple to create a java client for reading twitter messages using some third-party libraries such as Twitter4j, etc. You didnโt indicate which tweets you wanted to read, whether itโs your own tweets or someone elseโs, in any case, I followed this blog and did my job :)
- Attach the Twitter app to https://apps.twitter.com/app/new and get your consumer key. (Follow the indicated blog if you hit somewhere.)
- Using the Twitter4j API, get the authorization URL, click it and get a PIN. (The required code is listed below for your ref)
- Enter the output and get access to the window (see code below).
- Now we can all read or update twitter feeds. (Based on the access level that you set when you create the Twitter application)
Code example:
Twitter twitter = new TwitterFactory().getInstance(); twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_KEY_SECRET); RequestToken requestToken = twitter.getOAuthRequestToken(); System.out.println("Authorization URL: \n" + requestToken.getAuthorizationURL()); AccessToken accessToken = null; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try{ System.out.print("Hit above Authorization URL and Input PIN here: "); String pin = br.readLine(); accessToken = twitter.getOAuthAccessToken(requestToken, pin); } catch (TwitterException te) { System.out.println("Failed to get access token, caused by: " + te.getMessage()); } System.out.println("Access Token: " + accessToken.getToken()); System.out.println("Access Token Secret: " + accessToken.getTokenSecret());
Check it out and comment here if you encounter any problems.
source share