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,27 +29,19 @@ 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
require "redis"
require "redis-namespace"
require "weixin_authorize"
# don't forget change namespace
namespace = "your_app_name_weixin:weixin_authorize"
redis = Redis.new(:host => "127.0.0.1",:port => "6379", :db => 15)
namespace = "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.
# cleanup keys in the current namespace when restart server everytime.
exist_keys = redis.keys("#{namespace}:*")
exist_keys.each{|key|redis.del(key)}
......@@ -57,7 +51,16 @@ $client ||= WeixinAuthorize::Client.new(ENV["APPID"], ENV["APPSECRET"], "your_st
WeixinAuthorize.configure do |config|
config.redis = redis
end
```
* You can also specify the `key`, but it is optionly.
```ruby
$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