用户分组接口#

class wechatpy.client.api.WeChatGroup(client=None)[源代码]#
create(name)[源代码]#

创建分组

详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html

参数

name – 分组名字(30个字符以内)

返回

返回的 JSON 数据包

使用示例:

from wechatpy import WeChatClient

client = WeChatClient('appid', 'secret')
res = client.group.create('New Group')
delete(group_id)[源代码]#

删除分组

详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html

参数

group_id – 分组 ID

返回

返回的 JSON 数据包

使用示例:

from wechatpy import WeChatClient

client = WeChatClient('appid', 'secret')
res = client.group.delete(1234)
get(user_id=None)[源代码]#

查询所有分组或查询用户所在分组 ID

详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html

参数

user_id – 用户 ID,提供时查询该用户所在分组,否则查询所有分组

返回

所有分组列表或用户所在分组 ID

使用示例:

from wechatpy import WeChatClient

client = WeChatClient('appid', 'secret')
group = client.group.get('openid')
move_user(user_id, group_id)[源代码]#

移动用户分组

详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html

参数
  • user_id – 用户 ID, 可以是单个或者列表,为列表时为批量移动用户分组

  • group_id – 分组 ID

返回

返回的 JSON 数据包

使用示例:

from wechatpy import WeChatClient

client = WeChatClient('appid', 'secret')
res = client.group.move_user('openid', 1234)
update(group_id, name)[源代码]#

修改分组名

详情请参考 http://mp.weixin.qq.com/wiki/0/56d992c605a97245eb7e617854b169fc.html

参数
  • group_id – 分组id,由微信分配

  • name – 分组名字(30个字符以内)

返回

返回的 JSON 数据包

使用示例:

from wechatpy import WeChatClient

client = WeChatClient('appid', 'secret')
res = client.group.update(1234, 'New Name')