Skip to content

Instantly share code, notes, and snippets.

@juliosantos
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliosantos/d763ca0d7a0bc3945fdf to your computer and use it in GitHub Desktop.
Save juliosantos/d763ca0d7a0bc3945fdf to your computer and use it in GitHub Desktop.
Douche-B-Gone: forcing an API upon OkCupid to bulk block users
# DEMO: https://douche-b-gone.herokuapp.com/
require "httparty"
class Okcupid
def initialize(username: nil, password: nil)
@username = username
@password = password
get_authcode
get_session
end
def hide_users(usernames)
usernames.each do |username|
HTTParty.post( "https://api.okcupid.com/profile/#{username}/hide",
query: { access_token: @authcode },
headers: { "Cookie" => "session=#{@session}" }
)
#sleep 1
end
end
private
def guest_id
@guest_id ||= SecureRandom.random_number( 10000 )
end
def get_authcode
# regular login gets us the authcode
response = HTTParty.post( "https://www.okcupid.com/login",
body: { username: @username, password: @password },
headers: { "Cookie" => "guest=#{@guest_id}" },
)
@authcode = response.body.match( /AUTHCODE.*?"(.*)"/ )[1]
end
def get_session
# api login gets us the cookie and session in it
response = HTTParty.post( "https://www.okcupid.com/login",
body: { username: @username, password: @password, okc_api: 1 },
headers: { "Cookie" => "guest=#{@guest_id}" }
)
@session = response.headers["set-cookie"].match( / session=(.*?);/ )[1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment