Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
13ebb290
Commit
13ebb290
authored
Mar 22, 2014
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated README.md
parent
676c8751
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
22 deletions
+25
-22
README.md
+25
-22
No files found.
README.md
View file @
13ebb290
# WeixinAuthorize
# WeixinAuthorize
Support using
[
Redis
](
http://redis.io
)
to store
`access_token`
## Installation
## Installation
Add this line to your application's Gemfile:
Add this line to your application's Gemfile:
...
@@ -27,37 +29,38 @@ Or install it yourself as:
...
@@ -27,37 +29,38 @@ Or install it yourself as:
$client
||=
WeixinAuthorize
::
Client
.
new
(
ENV
[
"APPID"
],
ENV
[
"APPSECRET"
])
$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`
:
## Option: use [Redis](http://redis.io) to store your access_token (Recommend)
```
ruby
$client
||=
WeixinAuthorize
::
Client
.
new
(
ENV
[
"APPID"
],
ENV
[
"APPSECRET"
],
"your_store_key"
)
```
## 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`
*
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"
WeixinAuthorize
.
configure
do
|
config
|
require "redis-namespace"
config
.
redis
=
redis
require "weixin_authorize"
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.
* You can also specify the `
key
`, but it is optionly.
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.
```
ruby
redis = Redis::Namespace.new("#{namespace}", :redis => redis)
WeixinAuthorize.configure do |config|
$client
||=
WeixinAuthorize
::
Client
.
new
(
ENV
[
"APPID"
],
ENV
[
"APPSECRET"
],
"your_store_key"
)
config.redis = redis
```
end
**Note: ** `
your_store_key
` should be unique for every account!
```
### 获取用户管理信息
### 获取用户管理信息
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment