Commit 5f289652 by lanrion

removed new client from configure

parent 77ebcb22
...@@ -24,18 +24,29 @@ Or install it yourself as: ...@@ -24,18 +24,29 @@ Or install it yourself as:
```ruby ```ruby
$client ||= WeixinAuthorize.configure do |config|
config.app_id = ENV["APPID"]
config.app_secret = ENV["APPSECRET"]
config.expired_at = Time.now.to_i
end
# Or
$client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"]) $client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
``` ```
## Configure
* Create file in: config/initializers/weixin_authorize.rb
```ruby
require "redis"
require "redis-namespace"
require "weixin_authorize"
# don't forget change namespace
redis = Redis.new(:host => "127.0.0.1",:port => "6379")
# We suggest you use a special db in Redis, when you need to clear all data, you can use flushdb command to clear them.
redis.select(3)
# Give a special namespace as prefix for Redis key, when your have more than one project used weixin_authorize, this config will make them work fine.
redis = Redis::Namespace.new("your_app_name:weixin_authorize", :redis => redis)
WeixinAuthorize.configure do |config|
config.redis = redis
end
```
### 获取用户管理信息 ### 获取用户管理信息
* [获取用户基本信息](http://mp.weixin.qq.com/wiki/index.php?title=获取用户基本信息) * [获取用户基本信息](http://mp.weixin.qq.com/wiki/index.php?title=获取用户基本信息)
......
require "rest-client" require "rest-client"
require "multi_json" require "multi_json"
require "weixin_authorize/version" require "weixin_authorize/config"
require "weixin_authorize/api/user" require "weixin_authorize/api/user"
require "weixin_authorize/api/menu" require "weixin_authorize/api/menu"
require "weixin_authorize/api/custom" require "weixin_authorize/api/custom"
...@@ -9,15 +9,4 @@ require "weixin_authorize/client" ...@@ -9,15 +9,4 @@ require "weixin_authorize/client"
module WeixinAuthorize module WeixinAuthorize
# @client ||= WeixinAuthorize.configure do |config|
# config.app_id = "app_id-xxxxxxx"
# config.app_secret = "app_secret-xxxxxxx"
# end
#
class << self
def configure(&block)
Client.new(&block)
end
end
end end
...@@ -17,11 +17,6 @@ require "rspec" ...@@ -17,11 +17,6 @@ require "rspec"
require "weixin_authorize" require "weixin_authorize"
require "multi_json" require "multi_json"
# $client ||= WeixinAuthorize.configure do |config|
# config.app_id = ENV["APPID"]
# config.app_secret = ENV["APPSECRET"]
# config.expired_at = Time.now.to_i
# end
$client = WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"]) $client = WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment