Skip to content

Instantly share code, notes, and snippets.

Created May 8, 2014 03:14
Show Gist options
  • Select an option

  • Save anonymous/59dc98f6336a88d75b88 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/59dc98f6336a88d75b88 to your computer and use it in GitHub Desktop.
Ilbe storehouse user checker
# encoding: utf-8
require 'httparty'
module IB
class IBAgent
include HTTParty
base_uri 'www.ilbe.com'
format :plain
headers 'Referer' => 'http://www.ilbe.com/index.php?mid=index&act=dispMemberSignUpForm'
headers 'User-Agent' => 'Input your user-agent here'
headers 'X-Requested-With' => 'XMLHttpRequest'
headers 'Content-Type' => 'text/plain'
def check_id(user_id)
xml = xml_id(user_id)
options = { :body => xml }
data = self.class.post('/index.php', options)
data.include?('이미')
end
def check_email(user_email)
xml = xml_email(user_email)
options = { :body => xml }
data = self.class.post('/index.php', options)
data.include?('다른')
end
private
def xml_id(user_id)
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n \
<methodCall>\n<params>\n<name><![CDATA[user_id]]></name>\n \
<value><![CDATA[#{user_id}]]></value>\n<module><![CDATA[member]]></module>\n \
<act><![CDATA[procMemberCheckValue]]></act>\n</params>\n</methodCall>"
end
def xml_email(user_email)
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n \
<methodCall>\n<params>\n<name><![CDATA[email_address]]></name>\n \
<value><![CDATA[#{user_email}]]></value>\n<module><![CDATA[member]]></module>\n \
<act><![CDATA[procMemberCheckValue]]></act>\n</params>\n</methodCall>"
end
end
def agent; IBAgent.new end
# original text: 이미 존재하는 아이디입니다. 다른 아이디를 입력해주세요.
def check_id(user_id)
agent.check_id(user_id)
end
# original text: 사용하실 수 없는 메일 주소입니다. 다른 메일 주소를 입력해주세요.
def check_email(user_email)
agent.check_email(user_email)
end
module_function :agent, :check_id, :check_email
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment