wx_ext 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 797ac4daf9107e77b285eee805cb71bb5823a3af
4
- data.tar.gz: ccf4970ab608529ef2dd21e06ff39cba034982f8
3
+ metadata.gz: 11f6350756900eb4f1151d46a2ed8db198b630e1
4
+ data.tar.gz: 1805b3f7dc380df8509b83665a8b6c9559b26c12
5
5
  SHA512:
6
- metadata.gz: dc9ecd44eb86193b226ed4529c3ddc15321852bd41f5dde86ea8fdedd5a6df1ba2693937325ca8a1d81cff6a10a212b5af71bbbd9200f3b085a7b906f0014a46
7
- data.tar.gz: f5f5f609b2fcd25814d24583fb6c95b533fe46a30f60cda3c16b6e4dcad9e3e00e3224d24cd2b4862c0777887b1768dfcda2ccb6cd86fe8ba1ebb95b0facd8b5
6
+ metadata.gz: de1796e01dfe58fe60a5999258e56e1b72acc5b9d94bba72d27bfee5e1e1041b7d608ed9116b1cdba93f5c2a956c15b40f0be316f985c6d61f0e45fdd74e97f6
7
+ data.tar.gz: 5adad9873d3c6d8b98bd600bb40d930cdc2e311408e58b1af5dfda06561e3be10c334d1a19f0244b55ac9f31f12ce867f54c2240be83f186b9cd9ceafa552dc5
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'wx_ext', '~> 0.0.4'
10
+ gem 'wx_ext', '~> 0.0.6'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module WxExt
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
data/lib/wx_ext.rb CHANGED
@@ -242,13 +242,14 @@ module WxExt
242
242
  day_msg_count.to_i
243
243
  end
244
244
 
245
- # 获取 last_msg_id 和 msg_item
246
- def get_msg_item
247
- url = 'https://mp.weixin.qq.com/cgi-bin/message?t=message/list&count=20'\
248
- "&day=7&token=#{@token}&lang=zh_CN"
245
+ # 获取 total_count, count, day, frommsgid, can_search_msg, offset, action=search, keyword, last_msg_id, filterivrmsg=0/1 msg_items
246
+ def get_msg_items(count = 20, day = 7, filterivrmsg = 1, action='', keyword='', frommsgid='', offset='')
247
+ url = 'https://mp.weixin.qq.com/cgi-bin/message?t=message/list'\
248
+ "&action=#{action}&keyword=#{keyword}&frommsgid=#{frommsgid}&offset=#{offset}&count=#{count}"\
249
+ "&day=#{day}filterivrmsg=#{filterivrmsg}&token=#{@token}&lang=zh_CN"
249
250
  resource = RestClient::Resource.new(url, cookies: @cookies)
250
251
  res = resource.get
251
- reg = /.*total_count\s*:\s*(\d*).*latest_msg_id\s*:\s*\'(\d*)\'.*list\s*:\s*\((.*)\)\.msg_item,.*/m
252
+ reg = /.*total_count\s*:\s*(\d*).*latest_msg_id\s*:\s*\'(\d*)\'.*list\s*:\s*\((.*)\)\.msg_item,.*filterivrmsg\s*:\s*\"(\d*)\".*/m
252
253
  return_hash = {
253
254
  status: -1,
254
255
  msg: 'system_error'
@@ -259,12 +260,21 @@ module WxExt
259
260
  msg: 'ok',
260
261
  total_count: $1,
261
262
  latest_msg_id: $2,
262
- msg_item: JSON.parse($3)['msg_item']
263
+ count: 20,
264
+ day: 7,
265
+ frommsgid: '',
266
+ can_search_msg: '1',
267
+ offset: '',
268
+ action: '',
269
+ keyword: '',
270
+ msg_items: JSON.parse($3)['msg_item'],
271
+ filterivrmsg: $4
263
272
  }
264
273
  end
265
274
  return_hash
266
275
  end
267
276
 
277
+ # 获取粉丝数目
268
278
  def get_fans_count
269
279
  url = 'https://mp.weixin.qq.com/cgi-bin/contactmanage?t=user/index'\
270
280
  "&pagesize=10&pageidx=0&type=0&token=#{ @token }&lang=zh_CN"
@@ -289,7 +299,6 @@ module WxExt
289
299
  return_hash
290
300
  end
291
301
 
292
- # https://mp.weixin.qq.com/cgi-bin/singlesend?t=ajax-response&f=json&token=593714377&lang=zh_CN
293
302
  # {"base_resp":{"ret":10706,"err_msg":"customer block"}} 48小时内的才行
294
303
  # {"base_resp":{"ret":0,"err_msg":"ok"}}
295
304
  # 快速回复
data/spec/test.png ADDED
Binary file
@@ -5,7 +5,7 @@ describe WxExt::WeiXin do
5
5
  before(:all) do
6
6
  @weixin = WxExt::WeiXin.new 'flowerwrong@hotmail.com', '1*flower@wrong*1'
7
7
  end
8
-
8
+ =begin
9
9
  it 'should login to the mp' do
10
10
  res_hash = @weixin.login
11
11
  expect(res_hash[:status]).to eql(0)
@@ -64,6 +64,7 @@ describe WxExt::WeiXin do
64
64
  end
65
65
  end
66
66
 
67
+
67
68
  it 'should star msg' do
68
69
  res_hash = @weixin.login
69
70
  flag = @weixin.init
@@ -85,7 +86,7 @@ describe WxExt::WeiXin do
85
86
  expect(star_res_hash['ret'].to_s).to eql('0')
86
87
  end
87
88
  end
88
-
89
+ =end
89
90
 
90
91
  it 'should get fans count' do
91
92
  res_hash = @weixin.login
@@ -98,15 +99,20 @@ describe WxExt::WeiXin do
98
99
  end
99
100
  end
100
101
 
101
- it 'should get fakeids and msg ids' do
102
+ it 'should get total_count, count, day, frommsgid, can_search_msg, offset, action=search, keyword, last_msg_id, filterivrmsg=0/1 和 msg_items' do
103
+
102
104
  res_hash = @weixin.login
103
105
  flag = @weixin.init
104
- res_hash = @weixin.get_msg_item if flag
105
- puts '==' * 20
106
- puts res_hash
107
- expect(res_hash[:status]).to eql(0)
106
+ if flag
107
+ res_hash = @weixin.get_msg_items(20, 7, 1, '', '', '', '')
108
+ puts '==' * 20
109
+ puts res_hash
110
+ expect(res_hash[:status]).to eql(0)
111
+ else
112
+ puts 'init failed'
113
+ end
108
114
  end
109
-
115
+ =begin
110
116
  it "should get new msg num" do
111
117
  res_hash = @weixin.login
112
118
  flag = @weixin.init
@@ -262,5 +268,5 @@ describe WxExt::WeiXin do
262
268
  puts msg_hash["app_msg_info"]["item"][0]["app_id"]
263
269
  expect(msg_hash["base_resp"]["ret"].to_s).to eql("0")
264
270
  end
265
-
271
+ =end
266
272
  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.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - flowerwrong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-25 00:00:00.000000000 Z
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,6 +95,7 @@ files:
95
95
  - lib/wx_ext.rb
96
96
  - lib/wx_ext/version.rb
97
97
  - spec/spec_helper.rb
98
+ - spec/test.png
98
99
  - spec/wx_ext/weixin_spec.rb
99
100
  - wx_ext.gemspec
100
101
  homepage: http://thecampus.cc
@@ -123,4 +124,5 @@ specification_version: 4
123
124
  summary: a gem to hack mp.weixin.qq.com
124
125
  test_files:
125
126
  - spec/spec_helper.rb
127
+ - spec/test.png
126
128
  - spec/wx_ext/weixin_spec.rb