-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstreaming_api.rb
More file actions
executable file
·47 lines (35 loc) · 1.01 KB
/
Copy pathstreaming_api.rb
File metadata and controls
executable file
·47 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env ruby
require "rubygems"
require "date"
require "yaml"
require "net/http"
require "uri"
require "twitter_oauth"
require 'digest/md5'
require 'tweetstream'
require 'yajl'
yamlstring = ''
File.open("./auth.yaml", "r") { |f|
yamlstring = f.read
}
settings = YAML::load(yamlstring)
puts settings.inspect
if settings['access_token'].nil?
puts "use get_oauth.rb to fill out info for access_token and access_secret."
end
TweetStream.configure do |config|
config.consumer_key = settings['consumer_key']
config.consumer_secret = settings['consumer_secret']
config.oauth_token = settings['access_token']
config.oauth_token_secret = settings['access_secret']
config.auth_method = :oauth
config.parser = :yajl
end
track = ARGV[0].chomp
if track.nil?
puts 'track is nil. usage: ./streaming_api.rb keyword_to_track'
exit
end
TweetStream::Client.new.track(track) do |status|
puts "#{status.user.screen_name}: #{status.text} http://twitter.com/#{status.user.screen_name}/status/#{status.id}"
end