Configuring Twitter

First of all, Twitter and thus Twitter4J requires us to set up credentials so that we can access Twitter's API. If you have done that already, it will be easy to proceed further. If not, go to https://apps.twitter.com/ to create an application that can be used to obtain the credentials.

When the credentials are obtained, we will need to create a special Configuration object where the credentials will be stored:

final Configuration configuration = new ConfigurationBuilder()
.setDebugEnabled(true)
.setOAuthConsumerKey("enterYourDataHere")
.setOAuthConsumerSecret("enterYourDataHere")
.setOAuthAccessToken("enterYourDataHere")
.setOAuthAccessTokenSecret("enterYourDataHere")
.build();

That's it. The following line is useful to keep for debugging purposes while we are developing the application:

.setDebugEnabled(true)
.setDebugEnabled(true) can be replaced by .setDebugEnabled(BuildConfig.DEBUG) to turn off debugging automatically for release builds.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.251.128