Morphex's blogologue (Life, technology, music, politics, business, mental health and more)

This is the blog of Morten W. Petersen, aka. morphex in various places. I blog about my life, and what I find interesting and/or important. This is a personal blog without any editor or a lot of oversight so treat it as such. :)

My email is morphex@gmail.com.

I am leavingnorway.info.

An OGG/Vorbis player, implemented in Javascript.

My Kiva bragging page
My shared (open source) code on GitHub

Morphex's Blogodex

News
Me on Instagram
Slashdot

Zope hosting by Nidelven IT

Morten Petersen on Linkedin

Morten Petersen on Facebook

Morten Petersen on SoundCloud

Morten Petersen on MixCloud

Blogologue on Twitter



Older entries



Atom - Subscribe - Categories

Facebook icon Share on Facebook Google+ icon Share on Google+ Twitter icon Share on Twitter LinkedIn icon Share on LinkedIn

A Java-based tool to export tweets from Twitter for safe keeping

So, I was looking into exporting all my tweets the other day, to keep a copy just in case something happened to my Twitter account.

I tried exporting from Twitter (using a desktop browser as they asked on the export page), but I have so far not seen a dump of all my tweets.

I see there are other tools available for exporting Tweets, websites, but I thought to myself, why not create a simple, safe tool for exporting and safe-keeping Tweets.

So, after a bit of rummaging I found twitter4j, and started to build a Twitter export client using a text editor, a Makefile and javac/java.

However, I quickly ran into a NoClassDefFoundError, and after googling a bit, I felt an obscure-configuration-detail-headache coming on, and decided I could try to use Maven, which is mentioned on the Twitter4j website for the build process.

The Maven quickstart guide instructed me to use this command to generate a Maven project:

mvn archetype:generate -DgroupId=org.morphex.app -DartifactId=twitter-exporter -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

And after downloading some components etc. - Maven had a file hierarchy for me.

I then added the following section to pom.xml

    <dependency>
      <groupId>org.twitter4j</groupId>
      <artifactId>twitter4j-core</artifactId>
      <version>4.0.4</version>
    </dependency>

To include the twitter4j components in the Maven project. I then preceeded to run "mvn package" and then entered the target directory, and with the command

java -cp ./twitter-exporter-1.0-SNAPSHOT.jar org.morphex.app.App

I got the result

Hello World!

Which is what one can expect, as the project was just generated. Afterwards I created a new repository on GitHub, and uploaded the project (output of "history|grep git" in bash):

 2172  git init
 2173  git add pom.xml src
 2175  git config --global user.email "morphex@gmail.com"
 2176  git config --global user.name "Morten W. Petersen"
 2177  git commit
 2182  git remote add origin https://github.com/morphex/twitter-exporter.git
 2183  git push -u origin master
 2184  history|grep git

I started with this before I decided to blog about it, so I guess to setup the enviroment you have to run "sudo apt install maven openjdk-8-jdk openjdk-8-jre git" on Ubuntu/Debian.

The source code website for the project is here: https://github.com/morphex/twitter-exporter

[Update same day: I had to download the twitter4j jar and add it to the java command above: "java -cp ./twitter-exporter-1.0-SNAPSHOT.jar:./twitter4j-core-4.0.4.jar org.morphex.app.App"]

[Update later same day: twitter4j-core-4.0.4.jar can be downloaded from http://twitter4j.org/maven2/org/twitter4j/twitter4j-core/4.0...]

[And update even later same day: twitter4j-core-4.0.6.jar can be downloaded from https://repo1.maven.org/maven2/org/twitter4j/twitter4j-core/... - it's necessary for the latest code to run]

[Permalink] [By morphex] [Java (Atom feed)] [30 Mar 15:19 Europe/Oslo]