On: 2010/09/21 Viewed: 11214 times
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.

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

    Pages: « 1 2 [3] Show All

  1. 101
    Ozh »
    replied, on 18/Apr/14 at 5:43 pm # :

    Chip Bennett » go for it! The very reason I moved this on github was to foster contributions like this :)

  2. 102
    Chris United States »
    replied, on 22/Apr/14 at 6:04 am # :

    Hey Ozh, is there any reason this shouldn't work on shared server hosting? I'm seeing the automatic archiving hang fairly frequently. I've enabled the debug log (idk if you care, but that causes debug info to show in the plugin admin), but don't understand the log file. I'd be happy to email it if you'd like.

  3. 103
    Ozh »
    thought, on 22/Apr/14 at 8:08 am # :

    Chris » My own tweet archive is hosted on the most basic Dreamhost shared hosting, works fine. Not sure what you call "automatic archiving hang". Check the debug.log and see if something seems to cause that (eg: is it because it could not reach twitter? because it hit the twitter rate limit? etc…)

  4. 104
    Chris United States »
    commented, on 22/Apr/14 at 3:20 pm # :

    Ozh, thanks for the quick reply. I'm on the same hosting, so that must not be the issue. I had no problem manually importing tweets, but after it goes to automatic import, it doesn't seem to be importing. When reloading the setting page, I've seen "Next update in 59 minutes, 59 seconds" or "1 second" and currently it doesn't show a next update time. Nothing sticks out to me in the log file, although it does show 15 tweets skipped on each instance. It shows that it hits Twitter each instance.

  5. 105
    Chris United States »
    wrote, on 22/Apr/14 at 8:59 pm # :

    Ozh, another quick followup. Judging by the log, it looks like the cron is running every few minutes (2 minutes or so), even thought I've selected the option to run hourly. Can I send you the log file?

  6. 106
    Ozh »
    said, on 22/Apr/14 at 9:09 pm # :

    Chris » paste it somewhere

  7. 107
    Ozh »
    thought, on 22/Apr/14 at 9:59 pm # :

    Chris » no need to send the log file, I'm seeing the same problem. I'll investigate this and fix asap.

  8. 108
    Chris United States »
    wrote, on 22/Apr/14 at 11:54 pm # :

    Thanks, I appreciate it!

  9. 109
    Ozh »
    thought, on 23/Apr/14 at 4:21 pm # :

    Peeps: I've just pushed 2.0.1, update ASAP

  10. 110
    Chris United States »
    wrote, on 27/Apr/14 at 3:10 pm # :

    Hey Ozh, I'm still seeing automatic import fail. I have to trigger manual import, and after that automatic doesn't seem to work. Here's a log:

    http://pastebin.com/jp66e3YV

    I'm also seeing post formats not be applied on manual imports. Thanks for your help!

  11. 111
    Ozh »
    said, on 27/Apr/14 at 7:59 pm # :

    Chris » Dunno. This relates to the FAQ item #1

  12. 112
    Dave United States »
    replied, on 30/Apr/14 at 9:14 pm # :

    I can't believe I just came across this plugin today. Loving it!

    Has anyone written a script to import tweets older than the latest 3200? I'd be interested in that.

    Thanks,
    Dave

  13. 113
    Ozh »
    thought, on 01/May/14 at 12:09 am # :

    Dave » Yes, I wrote one. Updating the page with that info.

  14. 114
    Dave United States »
    commented, on 02/May/14 at 5:30 pm # :

    Ozh –

    The script worked great to import my remaining tweets. Thanks.

    One thing I'm noticing since I ran the script is that now when new tweets are imported they are being added as scheduled posts. Is this normal behavior?

    Thanks,
    Dave

  15. 115
    Ozh »
    replied, on 04/May/14 at 6:39 pm # :

    Dave » definitely not, there's no code to do such thing in my plugin

  16. 116
    Dave United States »
    commented, on 05/May/14 at 4:39 pm # :

    I did some testing and have more information. If I keep my blogs timezone set to UTC posts get published right away. If I set the timezone of the blog to my local time (UTC-4) posts get scheduled for later. This makes sense (I guess) because the the timestamp of the post is inherited from the tweet. The problem is that now all of my posts are timestamped 4 hours into the future of my actual timezone. (It's only ~10:30 AM local time but I have a post timestamped 11:47 AM today.) Would like to have the timestamps set to local time. Will look into this myself but if you have any thoughts that may help I'd be interested.

    Thanks again for the plugin (and the theme too).

    – Dave

  17. 117
    Ozh »
    replied, on 05/May/14 at 4:48 pm # :

    Dave » indeed the date & time are those from the tweet itself. I think what you need is to change that line to have a date() or strtotime() that complies to your WP install setup. If you happen to fix this, make sure to open a pull request with your fix :)

  18. 118
    Dave United States »
    said, on 05/May/14 at 7:50 pm # :

    I think changing that line to the following should do the trick:
    $date = date( 'Y-m-d H:i:s', strtotime( substr( $tweet->created_at, 0, strlen($tweet->created_at) – 5 )." ".get_option('gmt_offset') ));

    I'll add it to the version I'm running and see how it goes. Shouldn't take long to test.

    – Dave

  19. 119
    Ozh »
    wrote, on 05/May/14 at 10:35 pm # :

    Dave » I think you're overcomplicating stuff. Something like date( 'Y-m-d H:i:s', strtotime( $tweet->created_at ) + HOUR_IN_SECONDS * get_option('gmt_offset') ) looks enough to me (didn't test though)

  20. 120
    Dave United States »
    thought, on 05/May/14 at 11:00 pm # :

    Ozh –

    You're right. I was overthinking it. Your code works better than mine and is far less complicated. I have it working on my blog now will let it run an day or two to be sure it's working properly before opening a pull request.

    Thanks,
    Dave

  21. 121
    Ozh »
    thought, on 06/May/14 at 7:04 pm # :

    Dave » this needs testing with positive & negative offsets, though

  22. 122
    Dave United States »
    replied, on 06/May/14 at 7:43 pm # :

    Ozh – Understood. Doing that today. That's why I wanted to wait day or so before opening a pull request.

  23. 123
    JSantos Switzerland »
    thought, on 12/Jun/14 at 5:44 pm # :

    Hi,

    In both of my sites, first manual archive goes just fine and then later with auto archive some "tweets posts" lose the content of the post (entry) and they just keep the title of the post (obtaining 2 versions of the post in revision WP).
    I have tried different stuff, like changing timezone, uninstalling plugins, and finally it seems that since I desactivated JetPack everything seems to work ok.
    Very strange, I need to test now what part of JetPack is causing this incompatibility with OZH TweetArchiver.

    Thanks

Pages: « 1 2 [3] Show All

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.