I wanted a way to browse and search my old tweets, archive them in case Twitter ever dies, and do this all on my own web server. There were a few roundabout ways and hacky approaches to doing this out there, but I felt there were too many steps involved for something so simple, so I created Archive My Tweets. Now I have a browsable and searchable archive of all my tweets.

Due to a limitation of Twitter’s API, only the latest 3200 tweets can be retrieved. If you haven’t started grabbing your tweets now, you might want to get started so you don’t have to manually copy them in later.

Twitter Display Guidelines and Terms of Service

(August 17, 2012 update) After reading through Twitter’s new Display Guidelines, the Developer Rules of the Road, and the Terms of Service, I’m not convinced that Archive My Tweets falls under the new display guidelines.

As defined by Twitter, a Twitter Client allows a Twitter user to login, view his timeline (meaning tweets from people he follows), create new tweets, retweet, etc. Archive My Tweets does none of that; it’s only personal backup software.

My understanding is that using Archive My Tweets to store ones own tweets is allowed by their TOS. First, as described in the TOS, the creator of the content (the tweet) still owns all rights to that content after posting to Twitter. Second, the default Archive My Tweets setup is created in such a way that you should only be storing tweets that you’ve created. The way I see it, you’re just taking content you already own back from Twitter, and displaying that content in a manner that you choose.


58 Responses to “Archive My Tweets”

  1. Hi Andrew, many thanks for making this tool available, as well as the straightforward implementation instructions.

    I’d been frustrated with Twitter Tools (and its dependence upon another plugin for the scheduling) as it only pulled in a fraction of my tweets after the API change earlier this year.

    So starting afresh, using your tool (and the handy instructions on getting the Twitter archive transferred over from Twitter.com), I’m up and running again.

    Signed, very happy non-expert web blog person.

  2. Hi Andrew,

    Thank you for developing this tool. I installed this 3 days ago and had issues getting the cron.php working. When I looked through my server log for the errors, this is what it said:

    PHP Warning: Unexpected character in input: ‘\’ (ASCII=92) state=1 in /path/to/the/cron.php on line 14
    PHP Parse error: syntax error, unexpected T_STRING in /path/to/the/cron.php on line 14

    I’m not a php expert, however I did google potential solutions. Many say it has to do with my version of PHP. After running PHPinfo, my version says it is 5.3.27.

    Would you happen to know what it is? Any help you could offer would be great.

  3. Karen, is the actual Archive My Tweets website running just fine, for example, you’re seeing the pages and your tweets?

    If it’s running fine on the web, but your cron.php isn’t working, your host might have a different version of PHP running on the command line vs. the web. The error your getting points to your cron.php file being run with a version of PHP that’s some version of 5.2 or less. Version 5.3.0+ is required.

    In the documentation, see the Setting Up a Cron Job section, and try using one of the alternate methods there. That will force the cron.php file to be run under the same version of PHP that your website is using.

  4. Yes, the actual website is fine.

    I tried putting in “/usr/bin/env curl –silent –compressed http://example.com/tweets/cron.php?secret=MY_SECRET” but the cron email returned that I was not authorized.

  5. OK, so it’s almost working. Double check that the MY_SECRET part of your URL there matches the TWITTER_CRON_SECRET you’ve setup in your config.php file.

    Instead of waiting for cron to run again, you can also test it out by visiting that URL in your browser, and making sure the output is something besides “not authorized”: http://example.com/tweets/cron.php?secret=MY_SECRET

  6. It works!!! Turns out I was using the wrong secret. I checked it in the config.php file and it worked.

    Thank you for helping me work this out. 🙂 I really appreciate it.

  7. Roman Ožana

    11/27/2013 at 8:33 am

    Here is ultimate lastet nginx configuration

    location /tweets {
    rewrite ^/tweets/([0-9]+)/?$ /tweets/index.php?id=$1 last;
    rewrite “^/tweets/archive/([0-9]{4})/([0-9]{2})/([0-9]{2})/?$” /tweets/index.php?year=$1&month=$2&day=$3 last;
    rewrite “^/tweets/archive/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)/?$” /tweets/index.php?year=$1&month=$2&day=$3&page=$4 last;
    rewrite “^/tweets/archive/([0-9]{4})/([0-9]{2})/?$” /tweets/index.php?year=$1&month=$2 last;
    rewrite “^/tweets/archive/([0-9]{4})/([0-9]{2})/page/([0-9]+)/?$” /tweets/index.php?year=$1&month=$2&page=$3 last;
    rewrite “^/tweets/archive/([0-9]{4})/?$” /tweets/index.php?year=$1 last;
    rewrite “^/tweets/archive/([0-9]{4})/page/([0-9]+)/?$” /tweets/index.php?year=$1&page=$2 last;

    rewrite ^/tweets/client/(.*)/$ /tweets/index.php?client=$1 last;
    rewrite ^/tweets/client/(.*)/page/([0-9]+)/?$ /tweets/index.php?client=$1&page=$2 last;
    rewrite ^/tweets/page/([0-9]+)/?$ /tweets/index.php?page=$1 last;

    rewrite ^/tweets/favorites/?$ /tweets/index.php?favorites=1 last;
    rewrite ^/tweets/favorites/page/([0-9]+)/?$ /tweets/index.php?favorites=1&page=$2 last;
    rewrite ^/tweets/stats/?$ /tweets/index.php?method=stats last;

    port_in_redirect off;
    try_files $uri /tweets/index.php?$query_string;


  8. If your hosting provider doesn’t provide cron job, you may use easycron.com. It allows setting cron job that run every 10 minutes for free.

Leave a Reply