weixin_authorize 1.6.2 → 1.6.3

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: 7dcf07084b174215116839f53e3933a8360cd975
4
- data.tar.gz: 7e92dc7924d59e62f8f3f84f22b29947e2468c28
3
+ metadata.gz: a664fbdb47c8a23894a9fe8274f279e332b13152
4
+ data.tar.gz: b574af19ee28f8c01445b2ea886bcb727b4772f5
5
5
  SHA512:
6
- metadata.gz: b42caf728256adac156fabb2c4ebfe62b37a1b7b3d3916713164c6ec761d4d2de5863904e38c96d2d4c23b6698551c35849abd79007c0a9586a5dafddd0c914b
7
- data.tar.gz: 96acbc6e7563d3a44bdea2b9063e3b9fd1f43a00219cfe0d6ad91577c734a82dac144cec11fbb257917e1ca63396c515a5aa2f783c8815d2c33b867f0a09f6af
6
+ metadata.gz: 0062efdc2953202e3c42f3375421f00d81fee3586762cc1f231247daa7e1466adc7aa98f9511379d48a7b5a68cb3a535e5554bf723b58617ce24d13f6b7b52a2
7
+ data.tar.gz: 7060bc6ca0a181667f2be177b3b1ff750a566eb86c7adedf73d0dc572d47afe23a24ccc5875e619e32e8266808db21e58d911b00e2675260e404307b8ad5df27
data/README.md CHANGED
@@ -11,6 +11,21 @@ Support using [Redis](http://redis.io) to store `access_token`
11
11
 
12
12
  [Getting-Started](https://github.com/lanrion/weixin_authorize/wiki/Getting-Started)
13
13
 
14
+ [JS SDK](https://github.com/lanrion/weixin_authorize/wiki/js-sdk)
15
+
16
+ ## 已经完成API
17
+
18
+ * 客服消息
19
+ * 模板消息
20
+ * 用户分组管理
21
+ * 用户信息管理
22
+ * Oauth 2授权
23
+ * 二维码生成
24
+ * 自定义菜单
25
+ * 群发消息
26
+ * 多媒体管理
27
+ * JS SDK(ticket支持缓存)
28
+
14
29
  ## V2.0开发中:
15
30
  https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev
16
31
 
@@ -44,3 +59,9 @@ then run `rspec .`
44
59
  3. Commit your changes (`git commit -am 'Add some feature'`)
45
60
  4. Push to the branch (`git push origin my-new-feature`)
46
61
  5. Create new Pull Request
62
+
63
+ ## 捐赠支持
64
+
65
+ 如果你觉得我的gem对你有帮助,欢迎打赏支持,:smile:
66
+
67
+ ![](https://raw.githubusercontent.com/lanrion/my_config/master/imagex/donation_me.png)
@@ -1,9 +1,3 @@
1
- require "weixin_authorize/api/user"
2
- require "weixin_authorize/api/menu"
3
- require "weixin_authorize/api/custom"
4
- require "weixin_authorize/api/groups"
5
- require "weixin_authorize/api/qrcode"
6
- require "weixin_authorize/api/media"
7
- require "weixin_authorize/api/mass"
8
- require "weixin_authorize/api/oauth"
9
- require "weixin_authorize/api/template"
1
+ Dir["#{File.dirname(__FILE__)}/api/*.rb"].each do |path|
2
+ require path
3
+ end
@@ -7,8 +7,8 @@ module WeixinAuthorize
7
7
 
8
8
  # media_info= {"media_id" media_id}
9
9
  # https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=ACCESS_TOKEN
10
- def mass_with_group(group_id, media_info, msgtype="mpnews")
11
- group_option = {"filter" => {"group_id" => group_id.to_s}}
10
+ def mass_with_group(group_id, media_info, msgtype="mpnews", is_to_all=false)
11
+ group_option = {"filter" => {"group_id" => group_id.to_s, "is_to_all" => is_to_all}}
12
12
  media = generate_media(msgtype, media_info, group_option)
13
13
 
14
14
  mass_url = "#{mass_base_url}/sendall"
@@ -6,20 +6,30 @@ module WeixinAuthorize
6
6
 
7
7
  # 临时二维码
8
8
  def create_qr_scene(scene_id, expire_seconds=1800)
9
- post_url = "#{qrcode_base_url}/create"
10
9
  qrcode_infos = {action_name: "QR_SCENE", expire_seconds: expire_seconds}
11
- qrcode_infos = qrcode_infos.merge(action_info(scene_id))
12
- http_post(post_url, qrcode_infos)
10
+ qrcode_infos.merge!(action_info(scene_id))
11
+ http_post(qrcode_base_url, qrcode_infos)
13
12
  end
14
13
 
15
14
  # 永久二维码
16
- def create_qr_limit_scene(scene_id)
17
- post_url = "#{qrcode_base_url}/create"
15
+ # options: scene_id, scene_str
16
+ def create_qr_limit_scene(options)
17
+ scene_id = options[:scene_id]
18
18
  qrcode_infos = {action_name: "QR_LIMIT_SCENE"}
19
- qrcode_infos = qrcode_infos.merge(action_info(scene_id))
20
- http_post(post_url, qrcode_infos)
19
+ qrcode_infos.merge!(action_info(scene_id))
20
+ http_post(qrcode_base_url, qrcode_infos)
21
21
  end
22
22
 
23
+ # 为永久的字符串参数值
24
+ # options: scene_str
25
+ def create_qr_limit_str_scene(options)
26
+ scene_str = options[:scene_str]
27
+ qrcode_infos = {action_name: "QR_LIMIT_STR_SCENE"}
28
+ qrcode_infos.merge!(action_info(nil, scene_str))
29
+ http_post(qrcode_base_url, qrcode_infos)
30
+ end
31
+
32
+
23
33
  # 通过ticket换取二维码, 直接访问即可显示!
24
34
  def qr_code_url(ticket)
25
35
  WeixinAuthorize.mp_endpoint("/showqrcode?ticket=#{ticket}")
@@ -28,11 +38,14 @@ module WeixinAuthorize
28
38
  private
29
39
 
30
40
  def qrcode_base_url
31
- "/qrcode"
41
+ "/qrcode/create"
32
42
  end
33
43
 
34
- def action_info(scene_id)
35
- {action_info: {scene: {scene_id: scene_id}}}
44
+ def action_info(scene_id, scene_str=nil)
45
+ scene_info = {}
46
+ scene_info[:scene_id] = scene_id if !scene_id.nil?
47
+ scene_info[:scene_str] = scene_str if !scene_str.nil?
48
+ {action_info: {scene: scene_info}}
36
49
  end
37
50
 
38
51
  end
@@ -15,6 +15,8 @@ module WeixinAuthorize
15
15
 
16
16
  # 可选配置: RestClient timeout, etc.
17
17
  # key 必须是符号
18
+ # 如果出现 RestClient::SSLCertificateNotVerified Exception: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
19
+ # 这个错,除了改 verify_ssl: true,请参考:http://www.extendi.it/blog/2015/5/23/47-sslv3-read-server-certificate-b-certificate-verify-failed
18
20
  def rest_client_options
19
21
  if config.nil?
20
22
  return {timeout: 5, open_timeout: 5, verify_ssl: true}
@@ -1,3 +1,3 @@
1
1
  module WeixinAuthorize
2
- VERSION = "1.6.2"
2
+ VERSION = "1.6.3"
3
3
  end
@@ -49,6 +49,11 @@ describe WeixinAuthorize::Api::Mass do
49
49
  expect(response.code).to eq(WeixinAuthorize::OK_CODE)
50
50
  end
51
51
 
52
+ it "#mass_with_groug send to all" do
53
+ response = $client.mass_with_group("1", "mass_group_text_to_all", "text", true)
54
+ expect(response.code).to eq(WeixinAuthorize::OK_CODE)
55
+ end
56
+
52
57
  it "#mass_with_openids with mpnews and can delete message" do
53
58
  response = $client.mass_with_openids([ENV["OPENID"]], mass_media_id)
54
59
  expect(response.code).to eq(WeixinAuthorize::OK_CODE)
@@ -8,13 +8,13 @@ describe WeixinAuthorize::Api::Qrcode do
8
8
  end
9
9
 
10
10
  it "#create_qr_limit_scene" do
11
- response = $client.create_qr_limit_scene("1234")
11
+ response = $client.create_qr_limit_scene(scene_id: 1234, scene_str: "wechat")
12
12
  expect(response.code).to eq(WeixinAuthorize::OK_CODE)
13
13
  expect(response.result.keys).to eq(["ticket", "url"])
14
14
  end
15
15
 
16
16
  it "#return_qr_url" do
17
- response = $client.create_qr_limit_scene("1234")
17
+ response = $client.create_qr_limit_scene(scene_id: 1234, scene_str: "wechat")
18
18
  qr_url = $client.qr_code_url(response.result["ticket"])
19
19
  expect(response.code).to eq(WeixinAuthorize::OK_CODE)
20
20
  expect(qr_url).to match(/(\S+\.(com|net|org|edu|gov)(\/\S+)?)/)
@@ -0,0 +1,40 @@
1
+ describe WeixinAuthorize::Api::Template do
2
+ # {{first.DATA}}
3
+ # 项目名称:{{class.DATA}}
4
+ # 时间:{{time.DATA}}
5
+ # 地点:{{add.DATA}}
6
+ # {{remark.DATA}}
7
+ it "can send template msg" do
8
+ url = "http://www.baidu.com"
9
+ data = {
10
+ first: {
11
+ value: "报名结果通知",
12
+ color: "#173277"
13
+ },
14
+ class: {
15
+ value: "领导与管理课程培训/人格测评",
16
+ color: "#173177"
17
+ },
18
+ time: {
19
+ value: "11月6日—11月7日(周三—周五)",
20
+ color: "#274177"
21
+ },
22
+ add: {
23
+ value: "F302室",
24
+ color: "#274377"
25
+ },
26
+ remark: {
27
+ value: "您可点击【详情】查看详细信息。",
28
+ color: "#274377"
29
+ }
30
+ }
31
+ msg_result = $client.send_template_msg(
32
+ ENV["OPENID"],
33
+ ENV["TEMPLATE_ID"],
34
+ url,
35
+ "#173177",
36
+ data
37
+ )
38
+ expect(msg_result.code).to eq(WeixinAuthorize::OK_CODE)
39
+ end
40
+ end
data/spec/spec_helper.rb CHANGED
@@ -41,6 +41,7 @@ CodeClimate::TestReporter.start
41
41
  ENV["APPID"]="wx986f04063d341d04"
42
42
  ENV["APPSECRET"]="1a941cd88cb4579ba98ec06b6813af03"
43
43
  ENV["OPENID"]="o9k6BuB0kydAcPTc7sPxppB1GQqA"
44
+ ENV["TEMPLATE_ID"]="-8ooXrOK3VD3HuSS8--nH154PO9Lw2E7T-RV1uTaGLc"
44
45
 
45
46
  # Comment to test for ClientStorage
46
47
  redis = Redis.new(host: "127.0.0.1", port: "6379", db: 15)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weixin_authorize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - lanrion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -159,6 +159,7 @@ files:
159
159
  - spec/api/medias/ruby-logo.jpg
160
160
  - spec/api/menu_spec.rb
161
161
  - spec/api/qrcode_spec.rb
162
+ - spec/api/template_spec.rb
162
163
  - spec/api/user_spec.rb
163
164
  - spec/spec_helper.rb
164
165
  - weixin_authorize.gemspec
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
183
  version: '0'
183
184
  requirements: []
184
185
  rubyforge_project:
185
- rubygems_version: 2.4.5
186
+ rubygems_version: 2.2.2
186
187
  signing_key:
187
188
  specification_version: 4
188
189
  summary: weixin api authorize access_token
@@ -197,5 +198,6 @@ test_files:
197
198
  - spec/api/medias/ruby-logo.jpg
198
199
  - spec/api/menu_spec.rb
199
200
  - spec/api/qrcode_spec.rb
201
+ - spec/api/template_spec.rb
200
202
  - spec/api/user_spec.rb
201
203
  - spec/spec_helper.rb