weixin_public 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/weixin_public.rb +5 -4
- data/lib/weixin_public/version.rb +1 -1
- data/test/weixin_test.rb +5 -5
- metadata +1 -1
data/lib/weixin_public.rb
CHANGED
|
@@ -37,7 +37,7 @@ end
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class WeixinPubClient
|
|
40
|
-
def initialize(username,password,
|
|
40
|
+
def initialize(username,password,cert=nil,sig=nil)
|
|
41
41
|
@username=username
|
|
42
42
|
@password=password
|
|
43
43
|
@sig = sig
|
|
@@ -53,10 +53,10 @@ class WeixinPubClient
|
|
|
53
53
|
def login(username,pwd)
|
|
54
54
|
puts "login with#{username}-#{pwd}"
|
|
55
55
|
pwd = Digest::MD5.hexdigest(pwd)
|
|
56
|
-
|
|
57
56
|
@cookie = @cert?"cert=#{@cert}":""
|
|
57
|
+
@cookie = "#{@cookie};sig=#{@sig}"if @sig
|
|
58
58
|
params = {"username"=>username,"pwd"=>pwd,"imgcode"=>'',"f"=>'json'}
|
|
59
|
-
ret = request(:post,'/cgi-bin/login?lang=zh_CN',params,
|
|
59
|
+
ret = request(:post,'/cgi-bin/login?lang=zh_CN',params,"https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN")
|
|
60
60
|
return 'login failed' if !ret.headers["set-cookie"]
|
|
61
61
|
ret.headers["set-cookie"].split(',').each do |c|
|
|
62
62
|
@cookie << c.split(';')[0] <<";"
|
|
@@ -217,7 +217,8 @@ class WeixinPubClient
|
|
|
217
217
|
ret = @conn.post do |req|
|
|
218
218
|
req.url url
|
|
219
219
|
req.body = params
|
|
220
|
-
req.body['token']=@token
|
|
220
|
+
req.body['token']=@token if @token
|
|
221
|
+
p req.headers["Content-Length"]
|
|
221
222
|
end
|
|
222
223
|
else
|
|
223
224
|
ret = @conn.get do |req|
|
data/test/weixin_test.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require 'test/unit'
|
|
2
|
-
require 'weixin_public'
|
|
3
|
-
|
|
2
|
+
#require 'weixin_public'
|
|
3
|
+
require File.expand_path('../../lib/weixin_public.rb', __FILE__)
|
|
4
4
|
require 'openssl'
|
|
5
5
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
6
6
|
class WeixinPublicTest < Test::Unit::TestCase
|
|
7
7
|
def setup
|
|
8
|
-
@client = WeixinPublic::WeixinPubClient.new('
|
|
8
|
+
@client = WeixinPublic::WeixinPubClient.new('abc@gmail.com','123','JLj8zeaqZq6X2XH4eEq1YMGPziLCR5Bx','h0110f12d35cd47a953dcd05281fe1f7215dcb5bdeb45aa7c8ae48a2fbbd175a3377565a2f1de073531')
|
|
9
9
|
@fakeId = "1234567" #=>user who you want to send a message
|
|
10
10
|
@pic_file = "avatar.jpg"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def test_fans
|
|
14
14
|
@client.get_fans.each {|f| p "#{f.fakeId}-#{f.nickName}"}
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -38,7 +38,7 @@ class WeixinPublicTest < Test::Unit::TestCase
|
|
|
38
38
|
puts @client.avatar_upload(@pic_file)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def ntest_set_callback
|
|
42
42
|
@client.operadvancedfunc(2,1)
|
|
43
43
|
@client.set_dev_callback("http://wxpt2.cfapps.io/","abc")
|
|
44
44
|
end
|