@ -0,0 +1,5 @@ | |||||
source 'https://rubygems.org' | |||||
gem 'twitter' | |||||
gem 'inifile' | |||||
gem 'httparty' |
@ -0,0 +1,55 @@ | |||||
GEM | |||||
remote: https://rubygems.org/ | |||||
specs: | |||||
addressable (2.5.1) | |||||
public_suffix (~> 2.0, >= 2.0.2) | |||||
buftok (0.2.0) | |||||
domain_name (0.5.20160615) | |||||
unf (>= 0.0.5, < 1.0.0) | |||||
equalizer (0.0.11) | |||||
faraday (0.11.0) | |||||
multipart-post (>= 1.2, < 3) | |||||
http (2.2.2) | |||||
addressable (~> 2.3) | |||||
http-cookie (~> 1.0) | |||||
http-form_data (~> 1.0.1) | |||||
http_parser.rb (~> 0.6.0) | |||||
http-cookie (1.0.2) | |||||
domain_name (~> 0.5) | |||||
http-form_data (1.0.1) | |||||
http_parser.rb (0.6.0) | |||||
httparty (0.14.0) | |||||
multi_xml (>= 0.5.2) | |||||
inifile (3.0.0) | |||||
memoizable (0.4.2) | |||||
thread_safe (~> 0.3, >= 0.3.1) | |||||
multi_xml (0.6.0) | |||||
multipart-post (2.0.0) | |||||
naught (1.1.0) | |||||
public_suffix (2.0.5) | |||||
simple_oauth (0.3.1) | |||||
thread_safe (0.3.5) | |||||
twitter (6.1.0) | |||||
addressable (~> 2.5) | |||||
buftok (~> 0.2.0) | |||||
equalizer (= 0.0.11) | |||||
faraday (~> 0.11.0) | |||||
http (~> 2.1) | |||||
http_parser.rb (~> 0.6.0) | |||||
memoizable (~> 0.4.2) | |||||
naught (~> 1.1) | |||||
simple_oauth (~> 0.3.1) | |||||
unf (0.1.4) | |||||
unf_ext | |||||
unf_ext (0.0.7.2) | |||||
PLATFORMS | |||||
ruby | |||||
DEPENDENCIES | |||||
httparty | |||||
inifile | |||||
BUNDLED WITH | |||||
1.14.4 |
@ -0,0 +1,35 @@ | |||||
Encoding.default_internal = 'UTF-8' | |||||
require 'rubygems' | |||||
require 'bundler/setup' | |||||
require 'json' | |||||
Bundler.require | |||||
$config = IniFile.load('../.env') | |||||
client = Twitter::Streaming::Client.new do |config| | |||||
config.consumer_key = $config['global']['TWITTER_CONSUMER_KEY'] | |||||
config.consumer_secret = $config['global']['TWITTER_CONSUMER_SECRET'] | |||||
config.access_token = $config['global']['TWITTER_ACCESS_TOKEN'] | |||||
config.access_token_secret = $config['global']['TWITTER_ACCESS_TOKEN_SECRET'] | |||||
end | |||||
client.user do |obj| | |||||
case obj | |||||
when Twitter::Tweet | |||||
puts "Got a tweet" | |||||
puts obj.to_h.to_json | |||||
response = HTTParty.post "#{$config['global']['APP_URL']}/twitter/stream", { | |||||
body: obj.to_h.to_json, | |||||
headers: {'Content-Type' => 'application/json'} | |||||
} | |||||
when Twitter::DirectMessage | |||||
puts "Got a DM" | |||||
when Twitter::Streaming::DeletedTweet | |||||
puts "Someone deleted a tweet" | |||||
when Twitter::Streaming::StallWarning | |||||
puts "Falling behind!" | |||||
end | |||||
end | |||||
@ -0,0 +1,14 @@ | |||||
Encoding.default_internal = 'UTF-8' | |||||
require 'rubygems' | |||||
require 'bundler/setup' | |||||
require 'json' | |||||
Bundler.require | |||||
$config = IniFile.load('../.env') | |||||
response = HTTParty.post "#{$config['global']['APP_URL']}/twitter/stream", { | |||||
body: IO.read("tweet.json"), | |||||
headers: {'Content-Type' => 'application/json'} | |||||
} | |||||
puts response |