forked from jefflinwood/twitter2twilio
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial checkin of Tweeter Keeper ruby tool
- Loading branch information
1 parent
2b2caec
commit 2f0c19d
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Tweeter Keeper is built on top of other people's work - I didn't see any reason to reinvent the wheel. | ||
|
||
TweetStream gem - reads tweets off of Twitter's streaming API and provides a Ruby block with the tweets. | ||
|
||
Twitter gem - for use with the other Twitter API's - use to get followers for a user, user's tweet timeline, etc. We can use this to backfill in the history for users we follow on the streaming side. Some methods on this will require OAuth authentication | ||
|
||
MongoDB - NoSQL database that uses BSON (similar to JSON) for inserting and retrieving data, making it easy to dump data directly from Twitter without processing. | ||
|
||
Mongo gem - Use the Mongo Ruby Driver directly, instead of an abstraction library | ||
|
||
Install | ||
============= | ||
|
||
Environment - requires Ruby and MongoDB. | ||
|
||
gem install tweetstream | ||
gem install twitter | ||
gem install mongo | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'rubygems' | ||
require 'tweetstream' | ||
require 'mongo' | ||
|
||
#set up a connection to a local MongoDB | ||
@db = Mongo::Connection.new.db("tweeterkeeper") | ||
|
||
#all tweets will be stored in a collection called tweets | ||
@tweets = @db.collection("tweets") | ||
|
||
@tracking_keywords = Array['drupal','mongodb','three20']; | ||
|
||
@client = TweetStream::Client.new('USERNAME','PASSWORD') | ||
|
||
@client.on_delete do |status_id, user_id| | ||
puts "Removing #{status_id} from storage" | ||
@tweets.remove({"status" => status_id}) | ||
end | ||
|
||
@client.track(*@tracking_keywords) do |status| | ||
puts "#{status.text}" | ||
@tweets.insert(status) | ||
end |