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
2810c024
Commit
2810c024
authored
Mar 16, 2014
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added User apis
parent
b91ae9a5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
0 deletions
+44
-0
lib/weixin_authorize.rb
+1
-0
lib/weixin_authorize/api/user.rb
+29
-0
lib/weixin_authorize/client.rb
+1
-0
spec/api/user_spec.rb
+13
-0
No files found.
lib/weixin_authorize.rb
View file @
2810c024
require
"rest-client"
require
"rest-client"
require
"weixin_authorize/version"
require
"weixin_authorize/version"
require
"weixin_authorize/api/user"
require
"weixin_authorize/client"
require
"weixin_authorize/client"
module
WeixinAuthorize
module
WeixinAuthorize
...
...
lib/weixin_authorize/api/user.rb
0 → 100644
View file @
2810c024
# encoding: utf-8
module
WeixinAuthorize
module
Api
module
User
# 获取用户基本信息
# https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
# lang: zh_CN, zh_TW, en
def
user
(
openid
,
lang
=
"zh_CN"
)
user_info_url
=
"
#{
user_base_url
}
/info?
#{
access_token_param
}
&openid=
#{
openid
}
&lang=
#{
lang
}
"
JSON
.
parse
(
RestClient
.
get
(
user_info_url
))
end
# https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID
# 获取关注者列表
def
users
(
next_openid
=
nil
)
users_url
=
"
#{
user_base_url
}
/get?
#{
access_token_param
}
&next_openid
#{
next_openid
}
"
JSON
.
parse
(
RestClient
.
get
(
users_url
))
end
private
def
user_base_url
"
#{
endpoint
}
/user"
end
end
end
end
lib/weixin_authorize/client.rb
View file @
2810c024
...
@@ -4,6 +4,7 @@ module WeixinAuthorize
...
@@ -4,6 +4,7 @@ module WeixinAuthorize
class
Client
class
Client
attr_accessor
:app_id
,
:app_secret
,
:expired_at
# Time.now + expires_in
attr_accessor
:app_id
,
:app_secret
,
:expired_at
# Time.now + expires_in
include
Api
::
User
attr_accessor
:access_token
attr_accessor
:access_token
...
...
spec/api/user_spec.rb
0 → 100644
View file @
2810c024
require
"spec_helper"
describe
WeixinAuthorize
::
Api
::
User
do
it
"can get a weixin User info"
do
user_info
=
$client
.
user
(
ENV
[
"OPENID"
])
puts
user_info
end
it
"can get followers infos"
do
followers
=
$client
.
users
puts
followers
end
end
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