wechat 0.7.16 → 0.7.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README-CN.md +6 -6
- data/README.md +7 -7
- data/lib/action_controller/wechat_responder.rb +7 -3
- data/lib/wechat/controller_api.rb +2 -2
- metadata +2 -3
- data/Rakefile +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed2471f9aa568a83e09e3dfbe6515d037ee838c0
|
4
|
+
data.tar.gz: 6eb311ad860d7142dbd5d6fa5a62d2a1b40396b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0bb4fb7b20e03761990999d773136f667549d869623dc37dea64d8e8765d147b79e1fe5de4787d2f59953f8a3bbbe1b809d61b7c6d4a215257166125d99b9dd
|
7
|
+
data.tar.gz: 62471faa01c41258219c7bb3799aeea638630c8f5d97514b3cb4dd4520b25e2fe20872571031fc773f0fbff1bd65f2ab73839f8d0cf434dd96871a63c76ea353
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.7.17 (released at 8/18/2016)
|
4
|
+
|
5
|
+
* Allow declare wechat_api at ApplicationController, but using wechat at sub controller. #104
|
6
|
+
|
3
7
|
## v0.7.16 (released at 7/27/2016)
|
4
8
|
|
5
9
|
* FIX: consider '' in params as equal with nil, in ControllerApi#wechat_public_oauth2, by @snow #135
|
data/README-CN.md
CHANGED
@@ -159,7 +159,7 @@ production:
|
|
159
159
|
development:
|
160
160
|
<<: *default
|
161
161
|
trusted_domain_fullname: "http://your_dev.proxy.qqbrowser.cc"
|
162
|
-
|
162
|
+
|
163
163
|
test:
|
164
164
|
<<: *default
|
165
165
|
```
|
@@ -242,7 +242,7 @@ end
|
|
242
242
|
|
243
243
|
`wechat_oauth2`封装了OAuth2.0验证接口和cookie处理逻辑,用户仅需提供业务代码块即可。userid指的是微信企业成员UserID,openid是关注该公众号的用户openid。
|
244
244
|
|
245
|
-
注意:
|
245
|
+
注意:
|
246
246
|
* 如果使用 `wechat_responder`, 请不要在 Controller 里定义 `show` 和 `create` 方法, 否则会报错。
|
247
247
|
* 如果遇到“redirect_uri参数错误”的错误信息,请登录服务号管理后台,查看“开发者中心/网页服务/网页授权获取用户基本信息”的授权回调页面域名已正确配置。
|
248
248
|
|
@@ -497,15 +497,15 @@ $ wechat template_message oCfEht9oM*********** template.yml
|
|
497
497
|
在代码中可以这样使用:
|
498
498
|
|
499
499
|
```ruby
|
500
|
-
template = YAML.load(File.read(template_yaml_path))
|
501
|
-
Wechat.api.template_message_send Wechat::Message.to(openid).template(template)
|
500
|
+
template = YAML.load(File.read(template_yaml_path))
|
501
|
+
Wechat.api.template_message_send Wechat::Message.to(openid).template(template['template'])
|
502
502
|
```
|
503
503
|
|
504
504
|
若在Controller中使用wechat_api或者wechat_responder,可以使用wechat:
|
505
505
|
|
506
506
|
```ruby
|
507
|
-
template = YAML.load(File.read(template_yaml_path))
|
508
|
-
wechat.template_message_send Wechat::Message.to(openid).template(template)
|
507
|
+
template = YAML.load(File.read(template_yaml_path))
|
508
|
+
wechat.template_message_send Wechat::Message.to(openid).template(template['template'])
|
509
509
|
```
|
510
510
|
|
511
511
|
## wechat_api - Rails Controller Wechat API
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Wechat provides OAuth2.0 authentication method `wechat_oauth2`, possibly the eas
|
|
24
24
|
|
25
25
|
There is official [weui](https://github.com/weui/weui), which corresponding Rails gems called [weui-rails](https://github.com/Eric-Guo/weui-rails) available, if you prefer following the same UI design as wechat.
|
26
26
|
|
27
|
-
For web page only wechat application, please use [`wechat_api`](#wechat_api---rails-controller-wechat-api), which only contains web feature compare with traditional message type [`wechat_responder`](#wechat_responder---rails-responder-controller-dsl).
|
27
|
+
For web page only wechat application, please use [`wechat_api`](#wechat_api---rails-controller-wechat-api), which only contains web feature compare with traditional message type [`wechat_responder`](#wechat_responder---rails-responder-controller-dsl).
|
28
28
|
|
29
29
|
There is a more complete [wechat-starter](https://github.com/goofansu/wechat-starter) demo available, even include the payment SDK feature.
|
30
30
|
|
@@ -156,7 +156,7 @@ default: &default
|
|
156
156
|
token: ""
|
157
157
|
encoding_aes_key: ""
|
158
158
|
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
|
159
|
-
|
159
|
+
|
160
160
|
production:
|
161
161
|
corpid: <%= ENV['WECHAT_CORPID'] %>
|
162
162
|
corpsecret: <%= ENV['WECHAT_CORPSECRET'] %>
|
@@ -255,7 +255,7 @@ end
|
|
255
255
|
|
256
256
|
`wechat_oauth2` already implement the necessory OAuth2.0 and cookie logic. userid defined as the enterprise member UserID. openid defined as the user who following the public account, also notice openid will be different for the same user for different following public account.
|
257
257
|
|
258
|
-
Notice:
|
258
|
+
Notice:
|
259
259
|
* If you use `wechat_responder` in your controller, you cannot use `create` and `show` action in your controller, otherwise will throw errors.
|
260
260
|
* If you get *redirect_uri parameter error* message, make sure you set the correct callback site url value in wechat management console with path *Development center / Webpage service / Webpage authorization for retrieving user basic informaiton*.
|
261
261
|
|
@@ -512,15 +512,15 @@ $ wechat template_message oCfEht9oM*********** template.yml
|
|
512
512
|
In code:
|
513
513
|
|
514
514
|
```ruby
|
515
|
-
template = YAML.load(File.read(template_yaml_path))
|
516
|
-
Wechat.api.template_message_send Wechat::Message.to(openid).template(template)
|
515
|
+
template = YAML.load(File.read(template_yaml_path))
|
516
|
+
Wechat.api.template_message_send Wechat::Message.to(openid).template(template["template"])
|
517
517
|
```
|
518
518
|
|
519
519
|
If using wechat_api or wechat_responder in Controller, can alse use wechat as shortcut(Support multi account):
|
520
520
|
|
521
521
|
```ruby
|
522
|
-
template = YAML.load(File.read(template_yaml_path))
|
523
|
-
wechat.template_message_send Wechat::Message.to(openid).template(template)
|
522
|
+
template = YAML.load(File.read(template_yaml_path))
|
523
|
+
wechat.template_message_send Wechat::Message.to(openid).template(template["template"])
|
524
524
|
```
|
525
525
|
|
526
526
|
## wechat_api - Rails Controller Wechat API
|
@@ -2,12 +2,16 @@ module ActionController
|
|
2
2
|
module WechatResponder
|
3
3
|
def wechat_api(opts = {})
|
4
4
|
include Wechat::ControllerApi
|
5
|
-
self.
|
5
|
+
self.wechat_api_client = load_controller_wechat(opts)
|
6
6
|
end
|
7
7
|
|
8
8
|
def wechat_responder(opts = {})
|
9
9
|
include Wechat::Responder
|
10
|
-
self.
|
10
|
+
self.wechat_api_client = load_controller_wechat(opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def wechat
|
14
|
+
self.wechat_api_client ||= load_controller_wechat
|
11
15
|
end
|
12
16
|
|
13
17
|
private_class_method
|
@@ -25,7 +29,7 @@ module ActionController
|
|
25
29
|
Wechat.config.oauth2_cookie_duration ||= 1.hour
|
26
30
|
self.oauth2_cookie_duration = opts[:oauth2_cookie_duration] || Wechat.config.oauth2_cookie_duration.to_i.seconds
|
27
31
|
|
28
|
-
return self.
|
32
|
+
return self.wechat_api_client = Wechat.api if opts.empty?
|
29
33
|
if corpid.present?
|
30
34
|
Wechat::CorpApi.new(corpid, opts[:corpsecret], opts[:access_token], \
|
31
35
|
agentid, timeout, skip_verify_ssl, opts[:jsapi_ticket])
|
@@ -3,7 +3,7 @@ module Wechat
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
module ClassMethods
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :wechat_api_client, :token, :appid, :corpid, :agentid, :encrypt_mode, :timeout,
|
7
7
|
:skip_verify_ssl, :encoding_aes_key, :trusted_domain_fullname, :oauth2_cookie_duration
|
8
8
|
end
|
9
9
|
|
@@ -36,7 +36,7 @@ module Wechat
|
|
36
36
|
redirect_to oauth2_url
|
37
37
|
elsif cookies.signed_or_encrypted[:we_openid].blank? &&
|
38
38
|
params[:code].present? &&
|
39
|
-
params[:state].to_s == wechat.jsapi_ticket.oauth2_state.to_s # params[:state] maybe
|
39
|
+
params[:state].to_s == wechat.jsapi_ticket.oauth2_state.to_s # params[:state] maybe '' and wechat.jsapi_ticket.oauth2_state may be nil
|
40
40
|
access_info = wechat.web_access_token(params[:code])
|
41
41
|
cookies.signed_or_encrypted[:we_openid] = { value: access_info['openid'], expires: self.class.oauth2_cookie_duration.from_now }
|
42
42
|
yield access_info['openid'], access_info
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wechat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skinnyworm
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- LICENSE
|
133
133
|
- README-CN.md
|
134
134
|
- README.md
|
135
|
-
- Rakefile
|
136
135
|
- bin/wechat
|
137
136
|
- lib/action_controller/wechat_responder.rb
|
138
137
|
- lib/generators/wechat/install_generator.rb
|
data/Rakefile
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'rdoc/task'
|
9
|
-
rescue LoadError
|
10
|
-
require 'rdoc/rdoc'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
RDoc::Task = Rake::RDocTask
|
13
|
-
end
|
14
|
-
|
15
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
-
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = 'Wechat'
|
18
|
-
rdoc.options << '--line-numbers'
|
19
|
-
rdoc.rdoc_files.include('README.rdoc')
|
20
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
-
end
|
22
|
-
|
23
|
-
require File.join('bundler', 'gem_tasks')
|
24
|
-
require File.join('rspec', 'core', 'rake_task')
|
25
|
-
RSpec::Core::RakeTask.new(:spec)
|
26
|
-
|
27
|
-
task default: :spec
|