Created
August 5, 2009 16:22
-
-
Save woods/162792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Query twitter for all recent tweets by West Arete Computing and write them | |
# to a JSON file. | |
require 'rubygems' | |
require 'twitter' | |
require 'active_support' | |
# The users from whom we should fetch tweets tagged with #westarete | |
USERS = %w( creativeembassy coffeencoke westaretescott ) | |
# Get all tweets from user westarete. | |
westarete = Twitter::Search.new.from('westarete').fetch.results | |
# Get all tweets tagged #westarete from each of the users. | |
users = USERS.map { |user| Twitter::Search.new.from(user).hashed('westarete').fetch.results } | |
# Combine the results and sort by timestamp. | |
tweets = [westarete, users].flatten.sort_by { |tweet| tweet.created_at.to_time }.reverse | |
# Convert to json. | |
File.open('westarete_tweets.json', 'w') { |f| f.write(tweets.to_json) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment