Commit 13ebb290 by lanrion

updated README.md

parent 676c8751
# WeixinAuthorize
Support using [Redis](http://redis.io) to store `access_token`
## Installation
Add this line to your application's Gemfile:
......@@ -27,37 +29,38 @@ Or install it yourself as:
$client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"])
```
If you use [Redis](http://redis.io) to store your access_token, you can also specify the `key`:
```ruby
$client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"], "your_store_key")
```
## Option: use [Redis](http://redis.io) to store your access_token (Recommend)
## Configure to use Redis to store your access_token (Recommend)
**If you don't use Redis, it will send a request to get a new access_token everytime!**
* Create file in: `config/initializers/weixin_authorize.rb`
```ruby
```ruby
# don't forget change namespace
namespace = "app_name_weixin:weixin_authorize"
redis = Redis.new(:host => "127.0.0.1", :port => "6379", :db => 15)
# cleanup keys in the current namespace when restart server everytime.
exist_keys = redis.keys("#{namespace}:*")
exist_keys.each{|key|redis.del(key)}
# 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("#{namespace}", :redis => redis)
require "redis"
require "redis-namespace"
require "weixin_authorize"
WeixinAuthorize.configure do |config|
config.redis = redis
end
# don't forget change namespace
namespace = "your_app_name_weixin:weixin_authorize"
redis = Redis.new(:host => "127.0.0.1",:port => "6379", :db => 15)
```
# Delete the current namespace keys when restart everytime.
exist_keys = redis.keys("#{namespace}:*")
exist_keys.each{|key|redis.del(key)}
* You can also specify the `key`, but it is optionly.
# 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("#{namespace}", :redis => redis)
```ruby
WeixinAuthorize.configure do |config|
config.redis = redis
end
```
$client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"], "your_store_key")
```
**Note: ** `your_store_key` should be unique for every account!
### 获取用户管理信息
......
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