7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/juhe_ruby/id_verify.rb', line 7
def self.search(cardno, name, options=nil)
app_key = (options[:app_key] if options) || Juhe::IdVerify.app_key
url = BASE_URL +
"/index?key=" + app_key +
"&idcard=" + cardno +
"&realname=" + URI::encode(name)
result = JSON.parse(open(url).read)
if(result["error_code"] == 210301 or result["error_code"] == 210304)
result["error_code"] = 0
result["result"] = {
"realname"=> name,
"idcard"=> cardno,
"res"=> 2
}
end
raise result["reason"] if result["error_code"] != 0
result["result"]
end
|