uri = URI.parse('https://userstream.twitter.com/2/user.json')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.ca_file = './twitterstream.cert'
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.verify_depth = 5
http.start do |ses|
req = Net::HTTP::Get.new(uri.request_uri)
req.oauth!(ses,@consumer,@token)
buf = ""
ses.request(req) do |res|
res.read_body do |body|
buf << body
next if buf.index("\r\n").nil?
buf.chomp!.chomp!
status = JSON.parse(buf) rescue next
buf = ""
if status["text"].index("テン")
client.update("ガッ", :reply_id => status["id"])
end
end
end
end