Created
January 6, 2013 21:24
-
-
Save Jimgerneer/4470335 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
class RedditService | |
def self.post_report(report, token) | |
client = OAuth2::AccessToken.new(oauth_client, token) | |
url = "http://www.civbounty.com" | |
perp = Perpetrator.find(report.perpetrator_id) | |
user = User.find(report.user_id) | |
title = "Bounty of #{report.bounty}d placed on #{perp.name} CivBounty" | |
opts = { kind: 'link', url: url, title: title, sr: 'Rook'} | |
reddit_response = client.post("/api/submit", opts) | |
end | |
def self.oauth_client | |
@client ||= OAuth2::Client.new(ENV['REDDIT_KEY'], | |
ENV['REDDIT_SECRET'], | |
:site => 'https://oauth.reddit.com/', | |
:state => ## random ##) | |
end | |
end | |
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
#<OAuth2::Response:0x007fc415267b28 | |
@options={:parse=>nil}, | |
@response= | |
#<Faraday::Response:0x007fc415267bc8 | |
@env= | |
{:method=>:post, | |
:body=> | |
"{\"jquery\": [[0, 1, \"call\", [\"body\"]], [1, 2, \"attr\", \"find\"], [2, 3, \"call\", [\".status\"]], [3, 4, \"attr\", \"hide\"], [4, 5, \"call\", []], [5, 6, \"attr\", \"html\"], [6, 7, \"call\ | |
:url=> | |
#<URI::HTTPS:0x007fc41589c890 URL:https://oauth.reddit.com/api/submit>, | |
:request_headers=> | |
{"Authorization"=>"Bearer dBc1lT6Bfye1qB-blah-blah", | |
"Content-Length"=>"0"}, | |
:parallel_manager=>nil, | |
:request=>{:proxy=>nil}, | |
:ssl=>{}, | |
:status=>200, | |
:response_headers=> | |
{"date"=>"Sun, 06 Jan 2013 21:22:39 GMT", | |
"content-type"=>"application/json; charset=UTF-8", | |
"transfer-encoding"=>"chunked", | |
"connection"=>"close", | |
"vary"=>"Accept-Encoding", | |
"pragma"=>"no-cache", | |
"cache-control"=>"no-cache", | |
"set-cookie"=> | |
"reddit_first=%7B%22firsttime%22%3A%20%22first%22%7D; Domain=reddit.com; expires=Thu, 31 Dec 2037 23:59:59 GMT; Path=/", | |
"server"=>"'; DROP TABLE servertypes; --"}, | |
:response=>#<Faraday::Response:0x007fc415267bc8 ...>}, | |
@on_complete_callbacks=[]>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment