Created
November 13, 2012 03:38
-
-
Save vitorbaptista/4063793 to your computer and use it in GitHub Desktop.
Decaptcher.org API in Ruby
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
require 'net/http' | |
require 'uri' | |
require 'base64' | |
require 'pry' | |
KEY = "YOUR API KEY" | |
class Decaptcher | |
def initialize(file_name) | |
@file_name = file_name | |
@task_id = rand.to_s | |
end | |
def break | |
return @result if @result | |
uri = URI.parse("http://www.fasttypers.org/imagepost.ashx") | |
image = File.read(@file_name) | |
image_encoded = Base64.encode64(image) | |
params = { "action" => "upload", | |
"key" => KEY, | |
"file" => image_encoded, | |
"gen_task_id" => @task_id } | |
@result = Net::HTTP.post_form(uri, params).body | |
end | |
def ask_refund | |
uri = URI.parse("http://www.fasttypers.org/imagepost.ashx") | |
params = { "action" => "refund", | |
"key" => KEY, | |
"gen_task_id" => @task_id } | |
Net::HTTP.post_form(uri, params).body | |
end | |
def self.balance | |
uri = URI.parse("http://www.fasttypers.org/imagepost.ashx") | |
params = { "action" => "balance", | |
"key" => KEY } | |
Net::HTTP.post_form(uri, params).body.to_i | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment