wx_ext 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wx_ext/version.rb +1 -1
- data/lib/wx_ext/wei_xin.rb +8 -24
- data/spec/wx_ext/sougou_weixin_spec.rb +3 -1
- data/spec/wx_ext/weixin_spec.rb +11 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa847f05e1034eb2e61fcac47c4d55c99579faf
|
4
|
+
data.tar.gz: 7d73087550186218e099e861fd094c7d1007ad6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a567740a94e9f7803d7ca79e9f661351c4564c66bf5de0d9d8fca2360565090820a194075600a881a91f233049fc1ca24d545b6614e7c14eaa4f43bbcc94202e
|
7
|
+
data.tar.gz: 8efc54060cb6d784265f5c3afc0b81a8d1373e2528ec4c72216227ae76d2c991a2cb8fea5e1d80c3b1c14c8376fb990c38825e9017313f37a33f3a73e0c84117
|
data/lib/wx_ext/version.rb
CHANGED
data/lib/wx_ext/wei_xin.rb
CHANGED
@@ -100,25 +100,9 @@ module WxExt
|
|
100
100
|
bizuin: URI.unescape(cookies['bizuin'])
|
101
101
|
}
|
102
102
|
|
103
|
-
cookie_page = RestClient.get home_url, cookies: @cookies, headers: headers
|
104
|
-
@cookies = cookie_page.cookies
|
105
|
-
|
106
|
-
@cookies = {
|
107
|
-
slave_user: URI.unescape(cookies['slave_user']),
|
108
|
-
slave_sid: URI.unescape(cookies['slave_sid']),
|
109
|
-
bizuin: URI.unescape(cookies['bizuin'])
|
110
|
-
}
|
111
|
-
|
112
103
|
msg_send_url = 'https://mp.weixin.qq.com/cgi-bin/masssendpage'\
|
113
104
|
"?t=mass/send&token=#{@token}&lang=zh_CN"
|
114
105
|
msg_send_page = RestClient.get msg_send_url, cookies: @cookies
|
115
|
-
@cookies = msg_send_page.cookies
|
116
|
-
|
117
|
-
@cookies = {
|
118
|
-
slave_user: URI.unescape(cookies['slave_user']),
|
119
|
-
slave_sid: URI.unescape(cookies['slave_sid']),
|
120
|
-
bizuin: URI.unescape(cookies['bizuin'])
|
121
|
-
}
|
122
106
|
|
123
107
|
ticket_reg = /.*ticket\s*:\s*\"(\w+)\".*user_name\s*:\s*\"(.*)\",.*nick_name\s*:\s*\"(.*)\".*/m
|
124
108
|
operation_seq_reg = /.*operation_seq\s*:\s*\"(\d+)\".*/
|
@@ -162,8 +146,7 @@ module WxExt
|
|
162
146
|
'&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN'\
|
163
147
|
"&token=#{@token}"
|
164
148
|
}
|
165
|
-
resource = RestClient::Resource.new(@home_url, headers: headers,
|
166
|
-
cookies: @cookies)
|
149
|
+
resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)
|
167
150
|
res = resource[post_single_msg_uri].post single_msg_params
|
168
151
|
JSON.parse res.to_s
|
169
152
|
end
|
@@ -180,25 +163,26 @@ module WxExt
|
|
180
163
|
'?t=media/appmsg_edit&action=edit&type=10'\
|
181
164
|
"&isMul=1&isNew=1&lang=zh_CN&token=#{@token}"
|
182
165
|
}
|
183
|
-
resource = RestClient::Resource.new(@home_url, headers: headers,
|
184
|
-
cookies: @cookies)
|
166
|
+
resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)
|
185
167
|
post_msg_res = resource[uri].post msg_params
|
186
168
|
JSON.parse post_msg_res.to_s
|
187
169
|
end
|
188
170
|
|
189
171
|
# Preview broadcast news to user.
|
172
|
+
# system error: no data_bizuin and data_ticket in cookie
|
190
173
|
#
|
191
174
|
# @param [Hash] msg_params_with_name
|
192
175
|
# @return [Hash] A json parse hash.
|
193
176
|
def preview_msg(msg_params_with_name)
|
194
177
|
uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\
|
195
|
-
|
178
|
+
"&type=10&token=#{@token}&lang=zh_CN"
|
196
179
|
headers = {
|
197
180
|
referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\
|
198
|
-
|
181
|
+
"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}",
|
182
|
+
host: 'mp.weixin.qq.com',
|
183
|
+
x_requested_with: 'XMLHttpRequest'
|
199
184
|
}
|
200
|
-
resource = RestClient::Resource.new(@home_url, headers: headers,
|
201
|
-
cookies: @cookies)
|
185
|
+
resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)
|
202
186
|
|
203
187
|
res = resource[uri].post msg_params_with_name
|
204
188
|
# "ret":"0", "msg":"preview send success!", "appMsgId":"201796045", "fakeid":""
|
@@ -4,8 +4,9 @@ require 'spec_helper'
|
|
4
4
|
describe WxExt::SougouWeixin do
|
5
5
|
|
6
6
|
it 'should spider some posts from weixin.sougou.com' do
|
7
|
-
spider_posts = WxExt::SougouWeixin.spider_posts_from_sougou('
|
7
|
+
spider_posts = WxExt::SougouWeixin.spider_posts_from_sougou('oIWsFt7OVLOudxrGznZ_bMihIwKE', 1)
|
8
8
|
puts spider_posts[:spider_posts].count
|
9
|
+
# 从时间上看不一定是10
|
9
10
|
expect(spider_posts[:original_count]).to eql(10)
|
10
11
|
end
|
11
12
|
|
@@ -14,4 +15,5 @@ describe WxExt::SougouWeixin do
|
|
14
15
|
puts spider_posts[:spider_posts].count
|
15
16
|
expect(spider_posts[:total_pages].to_s).to match(/\d+/)
|
16
17
|
end
|
18
|
+
|
17
19
|
end
|
data/spec/wx_ext/weixin_spec.rb
CHANGED
@@ -22,7 +22,6 @@ describe WxExt::WeiXin do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
=begin
|
26
25
|
it 'should search msg with keyword' do
|
27
26
|
res_hash = @weixin.login
|
28
27
|
flag = @weixin.init
|
@@ -45,28 +44,30 @@ describe WxExt::WeiXin do
|
|
45
44
|
AppMsgId: '',
|
46
45
|
ajax: 1,
|
47
46
|
author0: '作者' + rand.to_s,
|
47
|
+
can_reward0: 0,
|
48
48
|
content0: '正文' + rand.to_s,
|
49
|
+
copyright_type0: 0,
|
49
50
|
count: 1,
|
50
51
|
digest0: 'test摘要' + rand.to_s,
|
51
52
|
f: 'json',
|
52
53
|
fileid0: file_id,
|
54
|
+
imgcode: '',
|
53
55
|
lang: 'zh_CN',
|
54
56
|
preusername: 'nan474947',
|
55
57
|
random: rand,
|
56
|
-
|
58
|
+
reward_wording0: '',
|
59
|
+
shortvideofileid0: '',
|
60
|
+
show_cover_pic0: 1, # 0 => 封面图片不显示在正文中
|
57
61
|
sourceurl0: 'http://thecampus.cc/' + rand.to_s,
|
58
62
|
title0: 'test标题' + rand.to_s,
|
59
63
|
token: @weixin.token,
|
60
64
|
vid: ''
|
61
65
|
}
|
62
|
-
|
63
66
|
msg_hash = @weixin.preview_msg(msg_params_with_name)
|
64
|
-
puts "==" * 20
|
65
|
-
puts msg_hash
|
66
67
|
expect(msg_hash["ret"].to_s).to eql("0")
|
67
68
|
end
|
68
69
|
|
69
|
-
|
70
|
+
=begin
|
70
71
|
it 'should reply to yang' do
|
71
72
|
res_hash = @weixin.login
|
72
73
|
flag = @weixin.init
|
@@ -78,7 +79,6 @@ describe WxExt::WeiXin do
|
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
|
-
|
82
82
|
it 'should star msg' do
|
83
83
|
res_hash = @weixin.login
|
84
84
|
flag = @weixin.init
|
@@ -100,7 +100,7 @@ describe WxExt::WeiXin do
|
|
100
100
|
expect(star_res_hash['ret'].to_s).to eql('0')
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
=end
|
104
104
|
|
105
105
|
it 'should get fans count' do
|
106
106
|
res_hash = @weixin.login
|
@@ -114,7 +114,6 @@ describe WxExt::WeiXin do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should get total_count, count, day, frommsgid, can_search_msg, offset, action=search, keyword, last_msg_id, filterivrmsg=0/1 和 msg_items' do
|
117
|
-
|
118
117
|
res_hash = @weixin.login
|
119
118
|
flag = @weixin.init
|
120
119
|
if flag
|
@@ -127,11 +126,10 @@ describe WxExt::WeiXin do
|
|
127
126
|
end
|
128
127
|
end
|
129
128
|
|
130
|
-
|
131
129
|
it "should get new msg num" do
|
132
130
|
res_hash = @weixin.login
|
133
131
|
flag = @weixin.init
|
134
|
-
msg_res_hash = @weixin.
|
132
|
+
msg_res_hash = @weixin.get_msg_items if flag
|
135
133
|
res_hash = @weixin.get_new_msg_num(msg_res_hash[:latest_msg_id=])
|
136
134
|
puts '==' * 20
|
137
135
|
puts res_hash
|
@@ -241,6 +239,7 @@ describe WxExt::WeiXin do
|
|
241
239
|
expect(msg_hash["ret"].to_s).to eql("0")
|
242
240
|
end
|
243
241
|
|
242
|
+
=begin
|
244
243
|
it "should broadcast msg to all user" do
|
245
244
|
res_hash = @weixin.login
|
246
245
|
flag = @weixin.init
|
@@ -273,6 +272,7 @@ describe WxExt::WeiXin do
|
|
273
272
|
puts msg_hash
|
274
273
|
expect(msg_hash["ret"].to_s).to eql("0")
|
275
274
|
end
|
275
|
+
=end
|
276
276
|
|
277
277
|
it 'should get app msg list with json' do
|
278
278
|
res_hash = @weixin.login
|
@@ -283,5 +283,4 @@ describe WxExt::WeiXin do
|
|
283
283
|
puts msg_hash["app_msg_info"]["item"][0]["app_id"]
|
284
284
|
expect(msg_hash["base_resp"]["ret"].to_s).to eql("0")
|
285
285
|
end
|
286
|
-
=end
|
287
286
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wx_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- flowerwrong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|