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
1692ed38
Commit
1692ed38
authored
Mar 16, 2014
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added groups apis
parent
307bdf68
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
0 deletions
+62
-0
lib/weixin_authorize.rb
+1
-0
lib/weixin_authorize/api/groups.rb
+53
-0
lib/weixin_authorize/client.rb
+1
-0
spec/api/groups_spec.rb
+7
-0
No files found.
lib/weixin_authorize.rb
View file @
1692ed38
...
...
@@ -3,6 +3,7 @@ require "weixin_authorize/version"
require
"weixin_authorize/api/user"
require
"weixin_authorize/api/menu"
require
"weixin_authorize/api/custom"
require
"weixin_authorize/api/groups"
require
"weixin_authorize/client"
module
WeixinAuthorize
...
...
lib/weixin_authorize/api/groups.rb
0 → 100644
View file @
1692ed38
# encoding: utf-8
module
WeixinAuthorize
module
Api
module
Groups
# 创建分组
# https://api.weixin.qq.com/cgi-bin/groups/create?access_token=ACCESS_TOKEN
def
create_group
(
group_name
)
create_url
=
"
#{
group_base_url
}
/create?
#{
access_token_param
}
"
group
=
MultiJson
.
dump
({
group:
{
name:
group_name
}})
JSON
.
parse
(
RestClient
.
post
(
create_url
,
group
))
end
# 查询所有分组
# https://api.weixin.qq.com/cgi-bin/groups/get?access_token=ACCESS_TOKEN
def
groups
groups_url
=
"
#{
group_base_url
}
/get?
#{
access_token_param
}
"
JSON
.
parse
(
RestClient
.
get
(
groups_url
))
end
# 查询用户所在分组
# https://api.weixin.qq.com/cgi-bin/groups/getid?access_token=ACCESS_TOKEN
def
get_group_for
(
openid
)
group_url
=
"
#{
group_base_url
}
/getid?
#{
access_token_param
}
"
openid
=
MultiJson
.
dump
({
openid:
openid
})
JSON
.
parse
(
RestClient
.
post
(
group_url
,
openid
))
end
# 修改分组名
# https://api.weixin.qq.com/cgi-bin/groups/update?access_token=ACCESS_TOKEN
def
update_group_name
(
group_id
,
new_group_name
)
group_url
=
"
#{
group_base_url
}
/update?
#{
access_token_param
}
"
group
=
MultiJson
.
dump
({
group:
{
id:
openid
,
name:
new_group_name
}})
JSON
.
parse
(
RestClient
.
post
(
group_url
,
group
))
end
# 移动用户分组
# https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=ACCESS_TOKEN
def
update_group_for_openid
(
openid
,
to_groupid
)
group_url
=
"
#{
group_base_url
}
/members/update?
#{
access_token_param
}
"
group
=
MultiJson
.
dump
({
openid:
openid
,
to_groupid:
to_groupid
})
JSON
.
parse
(
RestClient
.
post
(
group_url
,
group
))
end
private
def
group_base_url
"
#{
endpoint
}
/groups"
end
end
end
end
lib/weixin_authorize/client.rb
View file @
1692ed38
...
...
@@ -7,6 +7,7 @@ module WeixinAuthorize
include
Api
::
User
include
Api
::
Menu
include
Api
::
Custom
include
Api
::
Groups
attr_accessor
:access_token
...
...
spec/api/groups_spec.rb
0 → 100644
View file @
1692ed38
require
"spec_helper"
describe
WeixinAuthorize
::
Api
::
Groups
do
it
"create a group"
do
response
=
$client
.
create_group
(
"test"
)
response
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