confirmation_code 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/damatu.paw +1 -1
- data/lib/confirmation_code.rb +6 -2
- data/lib/confirmation_code/service/damatu.rb +13 -5
- data/lib/confirmation_code/service/lianzhong.rb +9 -0
- data/lib/confirmation_code/version.rb +1 -1
- data/run.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48e76ee1c36726f5269b0dfbee8f2d685f4d5a63
|
4
|
+
data.tar.gz: c54079ec1f5d17dfa12bc4adf8c17e106129bf83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a95fa035db2b647cf7e23e795185a736cf883199fd2adfaa5d55fbbbd63f5ba326fd17514103ff16d618fa8b1f448dc4694849137367a3315161043eccc6cc
|
7
|
+
data.tar.gz: e0098bc3e49827735c6e925138b67735efd70e4c18773e7d069638a7f5ca499a554396a2e4c4bba7471c80282c870351b611fa9234b8b5a7f72e0dbc5930fa85
|
data/damatu.paw
CHANGED
@@ -344,7 +344,7 @@
|
|
344
344
|
<attribute name="redirectauthorization" type="bool">0</attribute>
|
345
345
|
<attribute name="method" type="string">POST</attribute>
|
346
346
|
<attribute name="followredirects" type="bool">0</attribute>
|
347
|
-
<attribute name="body" type="string">[{"data":{"keyValues":[[["file"],[{"data":{"environmentVariable":"EAA39355-4AEE-4E2E-A045-F581429182EC"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true]]},"identifier":"com.luckymarmot.
|
347
|
+
<attribute name="body" type="string">[{"data":{"keyValues":[[["file"],[{"data":{"environmentVariable":"EAA39355-4AEE-4E2E-A045-F581429182EC"},"identifier":"com.luckymarmot.EnvironmentVariableDynamicValue"}],true]]},"identifier":"com.luckymarmot.BodyFormKeyValueDynamicValue"}]</attribute>
|
348
348
|
<attribute name="order" type="int64">2</attribute>
|
349
349
|
<attribute name="name" type="string">上传本地图片</attribute>
|
350
350
|
<relationship name="parent" type="0/1" destination="LMREQUESTTREEITEM" idrefs="z111"></relationship>
|
data/lib/confirmation_code.rb
CHANGED
@@ -17,9 +17,13 @@ module ConfirmationCode
|
|
17
17
|
@service
|
18
18
|
end
|
19
19
|
|
20
|
-
def upload(
|
20
|
+
def upload(image_path, options = {})
|
21
21
|
options = default_options.merge options
|
22
|
-
|
22
|
+
if image_path.start_with?('http')
|
23
|
+
@service.upload image_path, options if @service
|
24
|
+
else
|
25
|
+
@service.upload_local image_path, options if @service
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def account
|
@@ -15,6 +15,7 @@ module ConfirmationCode
|
|
15
15
|
HOST = 'http://api.dama2.com:7766'
|
16
16
|
|
17
17
|
UPLOAD_URL = File.join(HOST, 'app/d2Url?')
|
18
|
+
UPLOAD_LOCAL_URL = File.join(HOST, 'app/d2File?')
|
18
19
|
ACCOUNT_URL = File.join(HOST, 'app/d2Balance?')
|
19
20
|
RECOGNITION_ERROR_URL = File.join(HOST, 'app/d2ReportError?')
|
20
21
|
|
@@ -41,9 +42,6 @@ module ConfirmationCode
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def get_pwd(user, pwd)
|
44
|
-
ap md5(user)
|
45
|
-
ap md5(pwd)
|
46
|
-
ap md5(md5(user) + md5(pwd))
|
47
45
|
return md5(@app_key + md5(md5(user) + md5(pwd)))
|
48
46
|
end
|
49
47
|
|
@@ -61,6 +59,18 @@ module ConfirmationCode
|
|
61
59
|
result(JSON.parse(response.body))
|
62
60
|
end
|
63
61
|
|
62
|
+
def upload_local(image_path, options = {})
|
63
|
+
upload_options = damatu_options(options)
|
64
|
+
upload_options['type'] = 200 if upload_options['type'].nil?
|
65
|
+
byte_data = File.read(image_path)
|
66
|
+
File.open(image_path) do |file|
|
67
|
+
upload_options['file'] = file
|
68
|
+
upload_options['sign'] = sign(upload_options['user'], byte_data.bytes)
|
69
|
+
response = client.post(UPLOAD_LOCAL_URL, upload_options)
|
70
|
+
result(JSON.parse(response.body))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
64
74
|
def account(options = {})
|
65
75
|
account_options = damatu_options(options)
|
66
76
|
account_options['sign'] = sign(account_options['user'])
|
@@ -72,9 +82,7 @@ module ConfirmationCode
|
|
72
82
|
recognition_options = damatu_options(options)
|
73
83
|
recognition_options['id'] = ret_id.to_s
|
74
84
|
recognition_options['sign'] = sign(recognition_options['user'], ret_id.to_s.bytes)
|
75
|
-
ap recognition_options
|
76
85
|
response = client.post(RECOGNITION_ERROR_URL, recognition_options)
|
77
|
-
ap response.body
|
78
86
|
result(JSON.parse(response.body))
|
79
87
|
end
|
80
88
|
|
@@ -34,6 +34,15 @@ module ConfirmationCode
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def upload_local(image_path, options = {})
|
38
|
+
options = lianzhong_options.merge options
|
39
|
+
File.open(image_path) do |file|
|
40
|
+
options['upload'] = file
|
41
|
+
response = client.post(UPLOAD_URL, options)
|
42
|
+
result(JSON.parse(response.body))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
37
46
|
def account(options = {})
|
38
47
|
options = lianzhong_options.merge options
|
39
48
|
print options
|
data/run.rb
CHANGED
@@ -4,16 +4,16 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'confirmation_code'
|
5
5
|
|
6
6
|
#result = ConfirmationCode.upload 'https://passport.58.com/validatecode?temp=123i1knr04o'
|
7
|
-
|
8
7
|
ConfirmationCode.use :lianzhong, 'seaify', '67c86225'
|
9
8
|
ap ConfirmationCode.account
|
10
|
-
result = ConfirmationCode.upload('
|
9
|
+
result = ConfirmationCode.upload('0349.bmp')
|
10
|
+
ap ConfirmationCode.upload('http://captcha.qq.com/getimage')
|
11
11
|
ap result
|
12
12
|
ap ConfirmationCode.recognition_error result['data']['id']
|
13
|
-
return
|
14
13
|
|
15
14
|
ConfirmationCode.use :damatu, 'seaify', 'lsm123', {app_key: '0f80784a5ff20d38df3977e461e3d82a', app_id: '41635'}
|
16
|
-
ap ConfirmationCode.account
|
15
|
+
#ap ConfirmationCode.account
|
17
16
|
result = ConfirmationCode.upload('http://captcha.qq.com/getimage')
|
17
|
+
#result = ConfirmationCode.upload('0349.bmp')
|
18
18
|
ap result
|
19
19
|
ap ConfirmationCode.recognition_error result['data']['id']
|