Giter Club home page Giter Club logo

twitter-likes-backup's Introduction

Backup your Twitter likes (used to be called favorites)

This is a dirty way to get an off-site archive of your twitter likes and favorites as single JSON files.

Put this on a webserver of your choice that runs PHP.

The script will create a subdirectory tweets that will house the JSON files for each archived tweet. Also a max_id.txt, which logs the tweet ID used as offset in the API. Leave it alone.

Requirements

It's too bad you have to apply as a Twitter developer for this now. It used to be simple. Just get the tokens from this page: https://developer.twitter.com/apps

  • oauth_access_token
  • oauth_access_token_secret
  • consumer_key
  • consumer_secret

Enter the data into the $config array

Settings

Set the username and download amounts for each run. Shouldn't be so high that you run into the API limit (75 requests every 15 minutes?) For debugging, verbose mode can be useful, but for use in cron it's probably better to have it off.

Run

The import.php script can be run in the browser, eg. called via URL, but the preferred way is via CLI, eg. in cron Depending on your like count, you can run it frequently or less so. I have mine at once every 6 hours.

When the script is run, it requests tweets from the API and iterates over the result, saving every tweet it does not already have in the tweets directory. Every run it fetches about $config['count] times $config['max_iterations] tweets, so it may take quite a while until it has all your likes. Just let it do its thing. When it reaches the end ("the beginning of time"?), it will start over, requesting tweets again. This is because you may have likes tweets in the meantime that have early dates and would not show up if you only requested the latest likes.

Result

The result after a full cycle should be a directory ("folder") tweets, which contains your likes in JSON format, containing the exact API response. You can do anything with those; extract data and import into a database of your choosing, build a frontend to browse them, eg. in Javascript or PHP, use them in Apps, etc.

The files will be named after the tweet ID and, if possible, have a modification date of the tweet post timestamp. That can help looking up things. But in case the files are touched in any way, the mod date will be lost obviously.

Browsing

I included an early alpha release of a frontend to browse the tweets, index.php. In its current state it only supports searching for a term or simple browsing via pagination. This is untested with very large datasets. Handle with care!

Screen Shot 2021-05-30 at 00 33 31

Ending remarks

That's it. This is everything I can tell you. Good luck!

twitter-likes-backup's People

Contributors

oelna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.