Created
August 23, 2012 15:16
-
-
Save george/3437657 to your computer and use it in GitHub Desktop.
This file contains 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
https://papertrailapp.com/searches/95871.json | |
HTTP Basic: Access denied. | |
/Users/george/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/json/common.rb:148:in `parse': 743: unexpected token at 'HTTP Basic: Access denied. (JSON::ParserError) | |
' | |
from /Users/george/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/json/common.rb:148:in `parse' | |
from -:27:in `params_logs' | |
from -:48:in `<main>' |
This file contains 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
# harvests user name's and passwords from Heroku logs | |
require 'typhoeus' | |
require 'json' | |
class TopsoilLogs | |
BASE_URL = 'https://papertrailapp.com/api/v1' | |
API_TOKEN = 'xxxxxx'.freeze | |
def params_search_url | |
saved_searches.find { |search| | |
search['name'] == 'params' | |
}['_links']['self']['href'] | |
end | |
def saved_searches | |
response = Typhoeus::Request.get( saved_searches_url, | |
headers: { 'X-Papertrail-Token' => API_TOKEN } | |
) | |
JSON.parse(response.body) | |
end | |
def params_logs | |
response = Typhoeus::Request.get( params_search_url, | |
headers: { 'X-Papertrail-Token' => API_TOKEN } | |
) | |
JSON.parse(response.body) | |
rescue | |
puts response.body | |
puts | |
puts | |
raise | |
end | |
####### | |
private | |
####### | |
def saved_searches_url | |
"#{ BASE_URL }/searches.json" | |
end | |
end | |
logs = TopsoilLogs.new | |
puts logs.params_search_url | |
puts | |
puts logs.params_logs | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment