I have some code that perfectly returns a specific amount of tweets and appends them to a text file. However, i'm using Twitter4J version 4.0.4 and am need of editing the code so that it can return tweets that hold up to 256 characters (version 4.0.4 can only return 128 characters). I'm aware that version 4.0.6 supports 256 characters, but there is no download link to that version via the official site.
Does anyone have any suggestions of sources or ways of implementing the required changes in my code?
Cheers
public static void main(String [] args) throws TwitterException {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("xxx")
.setOAuthConsumerSecret("xxx")
.setOAuthAccessToken("xxx")
.setOAuthAccessTokenSecret("xxx");
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
java.util.List statuses = null;
String userName ="EmpireOfTheKop";
Paging page = new Paging (1, 50);
statuses = twitter.getUserTimeline(userName, page);
FileWriter fw;
File fileName;
try{
fileName = new File("LiverpoolTwo.txt");
fw = new FileWriter(fileName, true);
for (int i = 0; i < statuses.size(); i++) {
Status status = (Status)statuses.get(i);
String s = status.getUser().getName() + " : " + status.getText();
System.out.println(s);
fw.write(s);
}
fw.close();
}
catch (IOException e) {
System.err.println("Error. Cannot open file for writing.");
System.exit(1);
}
Twitter 4.0.6 supports 256 characters. While it may not be available as a direct download, it is available via Maven Central for use in a Maven-based project. Or, if you're not using maven, you can download the Jar it distributes and add it to your classpath directly.
If you are using Maven, add this to your POM:
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>4.0.6</version>
</dependency>
Or for Gradle:
compile group: 'org.twitter4j', name: 'twitter4j-core', version: '4.0.6'
If you want to download the jar directly, follow the link to Maven Central and click the "jar" link.