On: 2010/09/21
Shorter URL for this page: http://ozh.in/tq

Current version : 2.0 – compatible with Twitter's OAuth API

If you want to browse your own tweet history, Twitter sucks. If you have published more than 3200 tweets, Twitter lost the older ones. If you want to search a particular tweet about that awesome link you shared, you're toast. You can use #hashtags in your tweets but they won't be of any use to help you organize them. Oh, and those horrible t.co links.

On the other hand, WordPress does all this fine, so I made a plugin to archive all your tweets in WordPress, easily search them, and everything you wish Twitter would do.

Live Example

My tweet archive: Ozh' Tweets (notice the cool stats in the sidebar)

Download

Download the plugin :
ozh-tweet-archiver.zip
Extract and upload to your blog, preserving directory structure.

Plugin Usage

  • Install a fresh new empty blog (a subdirectory of your current blog will be fine, or a tweet.domain.com subdomain, it doesn't matter)
  • Install, activate the plugin, follow configuration instructions.

Features, Plugin Configuration

You'll need to create a Twitter application to obtain the consumer and secret keys. That'll be the hardest part.

screenshot-1

FAQ

Q: The [whatever] does not work!
A: WorksForMe.

Q: But [Other guy's plugin] does the same and more!
A: Exactly. "And more". I didn't need this.

Q: How are tweets imported?
A: As regular posts, with a few post custom fields (containing tweet source, "in reply to" data, etc). Hashtags can be converted as post tags if you wish (you'll want to do this), t.co links can be expanded to their original URLs, and some proper markup will be applied (see below, developer info)

Q: I tried to import all my tweets for the first time but the page died with an error / timeout / alien abduction !!1
A: Just hit F5 to reload the page. There will be no duplicates.

Q: I have more than 3200 tweets. How do I import & archive the old ones?
A: I wrote an importer script that uses this plugin. If it doesn't work for you, see first question of this FAQ (or write something yourself). The script: https://gist.github.com/ozh/11166845. There is another script with a similar approach, using data from the JSON files instead of the CSV one: https://gist.github.com/ozh/f5deafcffd8d271bfa92

Q: What theme did you use for your Tweet archive?
A: I made a theme for my own needs but it's freely available, feel free to use and hack it to make something for yourself: Ozh' Tweet Archive Theme.

Q: Can you add this or that feature?
A: This plugin was made to fit my needs. But hey, who knows, maybe I'll feel the need for your idea? Head to the Github repository and file a pull request.

Q: That one tweet got weirdly formatted/truncated when imported!
A: There's an "Edit post" link somewhere. That's the beauty of WordPress when compared to Twitter.

Q: Something doesn't work
A: Create a file named debug.log in this plugin's directory. This will activate the debug mode and a lot of things will be logged in that file. See if that helps. If not, see item #1 of this FAQ.

Theme developer stuff

Each tweet will be added some markup and classes, depending on your settings (if you want to link to @mentions, link to #hashtags as tags, etc…) to allow fine styling.

@mentions

When linked to Twitter profiles:

  1. <span class="username username_linked">@<a href="https://twitter.com/ozh" title="Ozh Richard">ozh</a></span>

Not linked:

  1. <span title="@ozh" class="username username_unlinked">@ozh</span>

#hashtags

You can elect to link hashtags to Twitter (as Twitter does), as local WordPress tags (much cooler), or to not link them. In each case, the markup for #bleh will be:

When linked to Twitter:

  1. <span class="hashtag hashtag_twitter">#<a href="https://twitter.com/search?q=#bleh">bleh</a></span>

When locally linked to WordPress tags:

  1. <span class="hashtag hashtag_local">#<a href="http://yoursite.com/tag/bleh">bleh</a>

Not linked:

  1. <span class="hashtag hashtag_no">#bleh</span>

Links

Links can be "un-t.co'd" (expanded)

  1. <a href="http://example.com" title="http://example.com" class="link link_untco">example.com</a>

Or kept as original t.co links:

  1. <a href="http://t.co/L4m3l1nk" class="link link_tco">http://t.co/L4m3l1nk</a>

Embedded media

If you enable embedding images from pic.twitter.com, you'll get the following:

  1. <span class="embed_image embed_image_yes"><a href="[image link]"><img src="[image src]" /></a></span>

Template tags

The plugin comes with a bunch of template tags to be used into your theme. Refer to file template_tags.php that comes with the plugin.

Shorter URL

Want to share or tweet this page? Please use this short URL: http://ozh.in/tq

Metastuff

This page "Ozh’ Tweet Archiver (Backup Twitter With WordPress)" was posted on 21/09/2010 at 11:12 pm
Watch this discussion : Comments RSS 2.0.

123 Blablas

  1. I LOVE this one in the FAQ:

    Q: The [whatever] does not work!
    A: Worksforme.

    Best plugin developer FAQ item ever. :) I'm writing up your plugin tonight. Thanks for your hard work on this one!

  2. deuts says:

    I'm loving this plugin. However, I just noted, my Twitter profile says I currently have 998 tweets so far, while my Tweet Archives' edit posts page in the admin area indicates I only have 968 posts so far. It means either the import is short by 30 tweets, or Twitter's count is over by 30.

  3. Ozh says:

    deuts » yeah I notice the same slight difference with my account. I guess DM's are counted (but not displayed, obviously), or maybe the Twitter API is just wrong :)

  4. deuts says:

    Oh, is that it? Anyway, I can leave without those 30 tweets. :D

  5. oriste says:

    Great plugin, fantastic idea. I have one problem: for over an hour now the manual archiving page says:

    1. Your browser will refresh this page in 38.5 seconds. If the page does not refresh, click here: Next please
    2.  
    3. Twitter is over capacity. This page will refresh in 90 seconds. Please wait this delay to avoid a ban.

    with the seconds counting down from 90 to 0, cycling ad infinitum over those 90 seconds.
    Would appreciate any suggestion.

  6. Max says:

    Thanks! Got this running on two accounts now.

  7. oriste says:

    Doh! Turns out the FAQ was right, especially the part that Sarah Gooding quotes.
    I've been debugging this thing well into the night without result, after which I decided to start from scratch this morning, deactivated and deleted the plugin, reinstalled it again and, voilà, it worked.
    I still don't know what happened, but now "Worksformetoo!" :D

  8. oriste says:

    I tweaked the theme a bit and my twitter archive looks great. I found one problem in the searchform.php module. My archive sits at the root of the domain oriste.gr (linked under my name). Searchform.php however contains this line:

    and returns a 404 in my case. Changing "/tweets/" to "/" solved the problem.

    I'd also like to take you up on the invite in the last item of the FAQ. I have way over 3200 tweets (so manually archiving only retrieves those), but I have been saving them all in json format files through backupmytweets.com. It would be neat if there would be a way to load such files as well. Just a suggestion, I'll understand if you don't feel the need for this idea.

    I tried it myself by tweaking the code to point $api to a location where my jason file resides (and omitting the optional parameters) but that didn't work. I'm not proficient enough in PHP or the WP framework to do this myself I'm afraid.

    Anyway I had a great time so far with your plugin, so thank you for that!

  9. oriste says:

    Oops, the code line in the previous post was eaten. Here it is (hopefully):

  10. oriste says:

    Giving up, it's the first line in searchform.php

  11. Ozh says:

    oriste » no surprise here, the theme is full of hardcoded stuff :) About the JSON archive from backupmytweets, can you send me this file? (ozh at ozh dot org) If the JSON structure is the same than the one produced by the API, it could be quite easy to import all tweets from this file.

  12. Import worked okay, but the time stamps are all off. I suspect it has to do with how you're handling GMT (or not). Here's an example from your own site:

    3:43pm Sep 24
    http://planetozh.com/tweets/3698

    10:43 AM Sep 24
    http://twitter.com/ozh/status/25415368585

    The above two seem to be the same tweet, but the date/time don't match. I believe the twitter API gives you GMT stamps. You could either check the time zone setting in WordPress, or check the time zone setting in the user's twitter profile. Then do the conversion before inserting into the 'posts' table.

    Thanks.

  13. Ozh says:

    Scott Crevier » I'll see what I can do (but I don't really mind to be honest)

  14. Joe Buhler says:

    OK, I should have first read about setting up a sub-directory before archiving all my tweets after installing the plug-in on my main blog. All tweets now show up there ahead of my blog posts! This is not what I wanted at all…. How can I either delete them or move them to a new sub-directory?
    Thanks for your assistance.

    Joe

  15. TwisterMc says:

    I tried your plugin with WordPress 3.1 and it failed.

    Main errors:
    Notice: add_option was called with an argument that is deprecated since version 2.3 with no alternative available.
    Notice: has_cap was called with an argument that is deprecated since version 2.0!
    Warning: Cannot modify header information

  16. TwisterMc says:

    Nevermind. It may have been another plugin and I just assumed. My bad.

    Seems to be working now. ;)

  17. Wouterjanss says:

    Is it possible to get more variables? like tweet link and inreply link?

  18. sjefen6 says:

    It causes a bug like this bug: http://wordpress.org/support/topic/plugin-audio-player-problems-after-update#post-1343872 when used with Audio Player. Sorry if you have adressed this…

  19. Jason Paul says:

    I like this plugin. Straight to the point. Is there anyway it can capture my Retweets as well?

  20. Brian says:

    Great plugin Ozh! Thank you sir. I'm using this on my website to pick up RT's from a twitter bot I made that will search for a certain #Tag tweeted by it's followers — to do that with your plugin I needed to change the json twitter API call to include_rts=true — problem being that when I have longer tweets posted to wordpress they're truncated after the RT @wsoppokerblog: part has been added… I'm looking to remove that 140 char limit for the wordpress posts but I'm not sure where to turn. Once again great job on this plugin and I thank you in advance for any help you can provide Cheers!

  21. Nader says:

    Why dose the Title/Subject and the Tweet have same contents, can I reduce the Post Title/Subject ?

    It looks dull, showing the same tweet twice

  22. Ozh says:

    Nader » It's a theme matter. Just edit your theme and make it look the way you want.

  23. Nader says:

    Dear Ozh,

    It was not a theme thing, I did the following modification on your php script (import.php)

    // Insert tweet as new post
    $post = array(
    'post_title' => ",
    'post_content' => $text,
    cheers.

  24. Ozh says:

    Nader » as I said: theme issue to me. I'd rather have a tweet archive theme that doesn't display both post title & content (eg http://planetozh.com/tweets/) than get an empty value.

  25. Brian says:

    Hi Ozh Thanks for a great plugin… Any thoughts on my issue. Posted at the top of page 2. Thanks!

  26. gadelkareem says:

    Thanks for the plugin..
    I have 2 features request
    – option to remove links and hashtags from title and shorten titles string.
    – option to process links and display them the way facebook does ex. youtube videos, images, website title and desc. ….etc

  27. Ozh says:

    gadelkareem » these are theme level tasks. Have your theme to do this.

  28. Carlos says:

    Hi Ozh:

    Thanks for your great plugin, but there is a problem: how can I say to the plugin where list the tweets? I tryed in a localhost and all tweets are in the main page, each tweet like each post. Where is the option to fil and say "list your tweets in this folder"?

    Regards

    Carlos

  29. Ozh says:

    Carlos » I'm not sure what you call a "folder". Anyway, this plugin imports tweets as posts so what you got is the normal behavior. In a future version I *might* add custom post type support.

  30. Carlos says:

    Hi Ozh:

    folder means "subdomain". doesn't matter, because I understand now this plugin better. i must use a new WP installation, DB included.

    Thanks a lot

    Carlos Xabier

  31. Ozh says:

    Carlos » note that you can simply activate multisite on your existing WP setup

  32. Carlos says:

    Thanks Oriste for your help.

    Regards

    Carlos

  33. rolf says:

    hello Ozh,

    thanks for your WP plug.

    questions:
    1. is it the plug or why do all my tweets show up double:
    http://www.quoteguruapp.com/blog/

    2. can you not put all tweets on 1 page i.e. http://www.quoteguruapp.com/twitterfeeds, instead of separate them as separate posts?

    thanks,
    rolf

  34. Ozh says:

    rolf » 1: Dunno. Worksforme. 2: theme job. Code your frontpage so it doesnt display posts from category "tweets" or whatever and display them in another page. Out of the scope of this plugin.

  35. deval says:

    i think your plugin does not work on wpmu…
    have you tried?
    thanks…

  36. deval says:

    sorry :D my bad…
    i give it few more chance to run on my server, now it works (on wpmu)!

    great plug-in indeed. thanks!

  37. XiaoKyun says:

    in wordpress hosted on dotcloud.com,
    it creates duplicates after running one day or two,
    all tweets imports twice,
    how to solve this error (may be aroused by dotcloud system)??

    thx

  38. Manuel says:

    Hi there, the plugin looks awesome, but I'm having a small problem as I've just run a "Manual Archiving", and only the last 140 tweets were imported (I have more than 2.000). I've tried doing a manual archive a couple of times more, but the plugin tells me that it's finished importing..

    Thanks a lot for your help.

    http://twitter.mediosordo.com/

  39. Dennis says:

    Great plugin – keep up the good work! :)

    I'm having some trouble with the import of my tweets though. Your plugin worked for a very short while, where it imported 4 tweets. Since it haven't imported my tweets at all… :-S

    I have tried everything and searched the web for an answer, but without any luck. So now I turn to you for help.

    It is the tweet stream on this frontpage: http://www.svadabryg.dk

  40. Dennis says:

    FINALLY! I have just found the solution to my import problem, which I have been searching for for weeks now!

    In my Twitter account the "only HTTPS" box had been checked, which apparently blocked the import of my tweets.

  41. Qays says:

    Hello,

    I'm considering installing this. You mention installing a new instance of WordPress. Is that necessary? Will there be negative consequences to installing it on a running instance?
    Thanks,
    Qays

  42. Ozh says:

    Qays » it'll import tweets as posts. Your blog posts will be mixed with your tweets.

  43. Qays says:

    Ok. That should be fine- kind of what I had in mind anyway. I'll probably give it a shot then. Take care.

  44. Stéphane Thibault says:

    Salut Ozh,

    Found a bug (post_tag parsing), found a bugfix. Are you still supporting this plugin ?

    I'd be happy to share this with you if you point me to the right place : )

  45. Ozh says:

    Stéphane Thibault » sure :)

  46. Murray says:

    Hi Ozh, am I able to select just tweets withing a certain date range to archive? For example, we run a twitter account that changes to a new tweeter each week. I want to preserve an record of each tweeters efforts, and archive on their profile page on our wordpress site. Could we adapt the plugin to somehow handle that? Thanks.

  47. gadelkareem says:

    Hi Ozh!
    I am here again and I modified import.php to be able to process the link and display a 'Facebook like' feed…check this Gadelkareem Tweets

    Great plugin!

  48. gadelkareem says:

    I thought I would share the code for expanding the links with you, please let me if you have better idea.
    Add full previews to your twitter feed on WordPress using Ozh’ Tweet Archiver

  49. TwisterMc says:

    We need to figure out how to get this to work with the new WordPress 3.4 Twitter shortcode.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.