blsm-mp-wx 0.2.6 → 0.2.7

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: 4e77b2dffef393a886b3c0a32dd5155eb4420836
4
- data.tar.gz: 625ed970fa8a13943b4bb496a226ba516388d984
3
+ metadata.gz: 7485f83a5b5038818e2ab3845c6ec95db95c7140
4
+ data.tar.gz: 150942cc1c2b3dc0f94153641dd95c272326e1fc
5
5
  SHA512:
6
- metadata.gz: bfe980a650d0b5904453cd74e430fd19bb2ededecf9bb5d8eefbfd065a70516a7d48ff6cbf0096364a90d89de14e18b39d4721b0da81d80364f0a86718c3d8a0
7
- data.tar.gz: 57e06e82f948f026bc703fb80722d5fc8a8ca6f355eac3c89763a225d39323e4c9f4b895bf1f84f3fd288eba19f3e920e8e16c6c496a63dc000d994162d85054
6
+ metadata.gz: 3745c7abee89ff7ec202bc9f9c0c5150eefb93c130b89656421dd74f6946fd3ddff54299652caf9cef0dd9e98867a6bc83216eb3931490081941a4bf9d7edb0d
7
+ data.tar.gz: 9dc5bd93b24c812f5eb8ea9d86d75e811f3527e0482f165721ebbd9f790a99e698e6f44caa8806096aa623a2c58ba2d2ff164b1643627de63948e99aea60ea4c
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://ruby.taobao.org'
2
2
 
3
3
  # Specify your gem's dependencies in blsm-mp-wx.gemspec
4
+ gem 'certified'
4
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blsm-mp-wx (0.2.5)
4
+ blsm-mp-wx (0.2.6)
5
5
 
6
6
  GEM
7
7
  remote: https://ruby.taobao.org/
@@ -35,6 +35,7 @@ GEM
35
35
  multi_json (~> 1.0)
36
36
  arel (3.0.3)
37
37
  builder (3.0.4)
38
+ certified (1.0.0)
38
39
  diff-lcs (1.2.5)
39
40
  erubis (2.7.0)
40
41
  faraday (0.9.1)
@@ -110,6 +111,7 @@ DEPENDENCIES
110
111
  activesupport (~> 3.2)
111
112
  blsm-mp-wx!
112
113
  bundler (~> 1.9)
114
+ certified
113
115
  faraday (~> 0.9)
114
116
  mysql2 (~> 0.3.16)
115
117
  rails (~> 3.2)
data/blsm-mp-wx.gemspec CHANGED
@@ -36,4 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "activerecord", "~> 3.2"
37
37
  spec.add_development_dependency "activesupport", "~> 3.2"
38
38
  spec.add_development_dependency "faraday", "~> 0.9"
39
+ spec.add_development_dependency "certified"
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module BlsmMpWx
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
data/lib/blsm-mp-wx.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # coding: utf-8
2
2
  require 'cgi'
3
3
  require 'rails'
4
+ require 'openssl'
5
+ require 'open-uri'
6
+ require 'net/https'
4
7
  require 'active_model'
5
8
  require 'active_record'
6
9
  require 'active_support'
@@ -314,6 +317,43 @@ module BlsmMpWx
314
317
  json_obj.inject({}) { |memo, (key, v)| memo[key.to_s.to_sym]=v; memo }
315
318
  end
316
319
 
320
+
321
+ def all_openid(app_id=nil, next_openid='', returned_openids = [])
322
+ app_id ||= self.APP_ID
323
+ p "getting openid... next_openid:#{next_openid}"
324
+
325
+ begin
326
+ conn = Faraday.new(:url => 'https://api.weixin.qq.com')
327
+ response = conn.get do |req|
328
+ req.url '/cgi-bin/user/get'
329
+ req.headers['Content-Type'] = 'application/json'
330
+ req.params[:access_token] = access_token(app_id)
331
+ req.params[:next_openid] = next_openid
332
+ end
333
+ response_body = response.body
334
+ p response_body
335
+ jobject = JSON.parse(response_body)
336
+
337
+ if jobject
338
+ if jobject['data'] && jobject['data']['openid']
339
+ p "total:#{jobject['total']},count:#{jobject['count']}"
340
+ returned_openids += jobject['data']['openid']
341
+ end
342
+
343
+ if jobject['next_openid'].to_s != ''
344
+ return all_openid(jobject['next_openid'], returned_openids)
345
+ end
346
+ end
347
+
348
+ if !jobject || jobject['next_openid'].to_s ==''
349
+ return returned_openids
350
+ end
351
+ rescue Exception => e
352
+ puts e
353
+ end
354
+ returned_openids
355
+ end
356
+
317
357
  private
318
358
  #解析json类型的数据,并将最后的数据转为hash或array
319
359
  # +json_data_str+ 要转换的json数据
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blsm-mp-wx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.9'
139
+ - !ruby/object:Gem::Dependency
140
+ name: certified
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  description: "包括access_token、js_api_ticket的获取,发送消息,模板消息,生成二维码,获取用户信息等。"
140
154
  email:
141
155
  - 15201280641@qq.com