Robb Knight: Code
A personal, searchable Twitter archive built with Laravel.
View a live demo
- See the Laravel requirements
- A twitter account
- Clone the repository
git clone https://github.com/rknight/one40.git one40
- Navigate to the root
- Create a copy of the example env file
cp .env.example .env.
.env, fill in your database details.
- Go to https://apps.twitter.com and create a new application to get your app keys, and put them in the env file. Note: set
PRIVATEto true if you don’t want your Twitter archive to be publicly accessible (we’ll create a user account in the next step).
php artisan key:generate
php artisan migrateto create the database tables
php artisan one40:setup; this will prompt for an email and password. This user account is used to login to one40 to see fetch logs and limit access to your archive (if the app is set to private).
Importing your archive
NB: You can request your Twitter archive here
To import your archive, move all the
(data/js/tweets/year_month.js) files to
resources/archive (create the
archive directory if it doesn’t exist) and run
php artisan one40:import. This can take a while depending on the size of your archive, so if it times out, just rerun it — one40 keeps track of which files it has imported, so it won’t re-run the same archive file twice.
Fetching new tweets
You can fetch new tweets by running
php artisan one40:fetch. This will import your most recent tweets (up to 3200) so it’s best to import a recent archive first. It’s recommended you setup a cron job to fetch new tweets on a schedule (although you can do it manually if you want). To fetch new tweets at midday every day, add this to your crontab:
1 12 * * * php /path/to/your/project/artisan one40:fetch
This article explains how to setup cron jobs.
The primary purpose of this is for me to be able to quickly search my tweets. I am aware there are some weird bugs with imported tweets being truncated and displaying in strange ways (see all issues) — I don’t have the time to fix them but I will happily accept pull requests that fix these issues.
I’m also aware of how messy a lot of the code is — a lot of the importing code is copy/pasted from Tweetnest. Again, I’ll happily accept PRs that improve this.
If you have an idea for a new feature, open an issue describing the feature so we can discuss if it before you put significant work into it.
Signifcant portions of the tweet importing logic is from Tweetnest licensed under MIT.