Created
January 11, 2013 17:23
-
-
Save D3MZ/4512456 to your computer and use it in GitHub Desktop.
Broken version of http://arfon.org/twitter-streaming-with-eventmachine-and-dynamodb
This file contains hidden or 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
require 'aws-sdk' | |
require 'eventmachine' | |
require 'tweetstream' | |
# create a table (50 read and 50 write capacity units) | |
# create primary key index using hash_key (:id) | |
#table = dynamo_db.tables.create("tweets", 10, 5, | |
# :hash_key => { :user_id => :number }, | |
# :range_key => { :created_at => :number }) | |
dynamo_db = AWS::DynamoDB.new(:access_key_id => AWS_ACCESS_KEY, :secret_access_key => AWS_SECRET_KEY) | |
table = dynamo_db.tables['tweets'] | |
table.load_schema | |
#loop do | |
# # count the number of items in the table (tweets) | |
# puts table.items.count | |
# | |
# sleep 3 | |
#end | |
TweetStream.configure do |config| | |
config.consumer_key = CONSUMER_KEY | |
config.consumer_secret = CONSUMER_SECRET | |
config.oauth_token = OAUTH_TOKEN | |
config.oauth_token_secret = OAUTH_TOKEN_SECRET | |
config.auth_method = :oauth | |
config.parser = :json_pure | |
end | |
client = TweetStream::Client.new | |
client.track("Bieber") do |status| | |
tweet_hash = {:user_id => status.user.id, | |
:created_at => status.created_at, | |
:id => status.id, | |
:screen_name => status.user.screen_name, | |
:location => status.user.location} | |
p table.items.create(tweet_hash) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment