Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 71fc3c95ec
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 43 lines (38 sloc) 1.459 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
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'pp'
require 'time'
require 'date'
require 'mongo'
require 'base64'
require 'typhoeus'

MONGO_HOST = ENV["MONGO_HOST"]
raise(StandardError,"Set Mongo hostname in ENV: 'MONGO_HOST'") if !MONGO_HOST
MONGO_PORT = ENV["MONGO_PORT"]
raise(StandardError,"Set Mongo port in ENV: 'MONGO_PORT'") if !MONGO_PORT
MONGO_USER = ENV["MONGO_USER"]
raise(StandardError,"Set Mongo user in ENV: 'MONGO_USER'") if !MONGO_USER
MONGO_PASSWORD = ENV["MONGO_PASSWORD"]
raise(StandardError,"Set Mongo user in ENV: 'MONGO_PASSWORD'") if !MONGO_PASSWORD
GS_USER = ENV["GS_USER"]
raise(StandardError,"Set GS user in ENV: 'GS_USER'") if !GS_USER
GS_PASSWORD = ENV["GS_PASSWORD"]
raise(StandardError,"Set Mongo user in ENV: 'GS_PASSWORD'") if !GS_PASSWORD

db = Mongo::Connection.new(MONGO_HOST, MONGO_PORT.to_i).db("gs")
auth = db.authenticate(MONGO_USER, MONGO_PASSWORD)
if !auth
  raise(StandardError, "Couldn't authenticate, exiting")
  exit
end

topicsColl = db.collection("topics")

ARGF.each_line do |url|
  t = topicsColl.find_one({"at_sfn" => url.chomp}, :fields => ["at_sfn", "id"])
  if t
    reply_url = "https://api.getsatisfaction.com/topics/"+t["id"].to_s+"/replies.json"
    result = Typhoeus::Request.post(reply_url,
              :username => GS_USER, :password => GS_PASSWORD,
              :params => { "reply" => {"content" => "roland test reply time:"+Time.now.to_s}})
    pp result
  end
end
Something went wrong with that request. Please try again.