Categorygithub.com/golanggo/hzs-wecom
modulepackage
1.0.7
Repository: https://github.com/golanggo/hzs-wecom.git
Documentation: pkg.go.dev

# README

版本变更日志参见 CHANGELOG.md

JetBrains Logo (Main) logo

更多相关文章将会在公众号分享,欢迎关注!

Geek进阶

文档

使用wecom-go-sdk快速开发企业微信自建应用

V2版本升级

http请求改用go-resty可方便指定重试、错误处理hooks(当前未处理)

使用

go get github.com/golanggo/hzs-wecom/v2
  • 增加SetProxy(proxyUrl string) 对绕过IP限制有用,可参考OpenResty(nginx)配置正向代理绕过企微自建IP限制

  • 增加SetDebug(debug bool) 可以监控http请求,看如下的输出

    GET  /cgi-bin/gettoken?corpid=wp0k1qEQAAiwQMWYzF8JOr99RJRX1_1A&corpsecret=Y2YbFpt95RcGTs9CvriQ2uj23Wl8B3IxtbRM9nKfjVU  HTTP/1.1
    HOST   : qyapi.weixin.qq.com
    HEADERS:
        Accept: application/json;charset=UTF-8
        Content-Type: application/json;charset=UTF-8
        User-Agent: wecom-go-sdk-v2
    BODY   :
    ***** NO CONTENT *****
    ------------------------------------------------------------------------------
    ~~~ RESPONSE ~~~
    STATUS       : 200 OK
    PROTO        : HTTP/2.0
    RECEIVED AT  : 2023-06-10T21:03:57.834584+08:00
    TIME DURATION: 181.642531ms
    HEADERS      :
        Content-Length: 176
        Content-Type: application/json; charset=UTF-8
        Date: Sat, 10 Jun 2023 13:03:58 GMT
        Error-Code: 40001
        Error-Msg: invalid credential, hint: [1686402237354962763423746], from ip: 123.116.182.237, more info at https://open.work.weixin.qq.com/devtool/query?e=40001
        Server: nginx
    BODY         :
    {
       "errcode": 40001,
       "errmsg": "invalid credential, hint: [1686402237354962763423746], from ip: 123.116.182.237, more info at https://open.work.weixin.qq.com/devtool/query?e=40001"
    }
    ==============================================================================
    
    

配置文件格式

CorpId: wwxxx
ProviderSecret: xxxxxxx
SuiteId: xxxxx
SuiteSecret: xxxxx-Gl8VA
SuiteToken: xxxxx
SuiteEncodingAesKey: xxxx
Dsn: user:pass@tcp(127.0.0.1:3306)/suite?charset=utf8mb4&parseTime=True&loc=Local
Port: 8080

 目录结构

├── config  解析yaml配置文件
├── example 样例程序
├── internal 内部函数,包含error和http请求
└── pkg 附加包
    └── svr 服务端接口部分
        ├── callback 指令及数据回调
        ├── install 应用安装连接生成、应用安装后的跳转
        ├── logic 各事件通知处理逻辑
        ├── middleware gin的中间件方便handler里引入sdk
        └── models  应用安装时常用到的表定义,基于gorm

第三方包

API列表

  • ID转换接口
    • corpid的转换
    • userid的转换
    • external_userid的转换
    • 客户标签ID的转换
    • 微信客服ID的转换
  • 身份验证
    • 网页授权登录
      • 获取访问用户身份
      • 获取访问用户敏感信息
    • 扫码授权登录
      • 获取登录用户信息
  • 应用授权
    • 调用第三方应用凭证
    • 获取预授权码
    • 设置授权配置
    • 获取企业永久授权码
    • 获取企业授权信息
    • 获取企业凭证 getCorpToken(存入数据库以主键代替)
    • 获取应用的管理员列表
    • 获取应用二维码
    • 回调接口pkg下svr使用gin框架的web接口
      • 推送suite_ticket
      • 授权通知事件 此部分与业务逻辑相关,仅做样例
        • 授权成功通知
        • 变更授权通知
        • 取消授权通知
      • 成员通知事件
      • 部门通知事件
      • 标签通知事件
      • 共享应用事件回调
      • 应用管理员变更回调
  • 通讯录管理
    • 成员管理
      • 创建成员
      • 读取成员
      • 更新成员
      • 删除成员
      • 获取部门成员
      • 获取部门成员详情
      • userid与openid互换
      • 二次验证
      • 邀请成员
      • 手机号获取userid
      • 获取成员授权列表
      • 查询成员用户是否已授权
      • 获取选人ticket对应的用户
      • 自建应用获取用户隐私信息
      • 获取成员ID列表
    • 部门管理
      • 创建部门
      • 更新部门
      • 删除部门
      • 获取部门列表
      • 获取子部门ID列表
      • 获取单个部门详情
    • 标签管理
      • 创建标签
      • 更新标签名字
      • 删除标签
      • 获取标签成员
      • 增加标签成员
      • 删除标签成员
      • 获取标签列表
    • 异步批量接口
    • 通讯录回调通知
    • 通讯录搜索
    • 通讯录ID转译
    • 通讯录userid排序
    • 异步导出接口
    • 推广二维码
  • 客户联系
    • 获取配置了客户联系功能的成员列表
    • 客户联系「联系我」管理
      • 配置客户联系「联系我」方式
      • 获取企业已配置的「联系我」方式
      • 获取企业已配置的「联系我」列表
      • 更新企业已配置的「联系我」方式
      • 删除企业已配置的「联系我」方式
      • 结束临时会话
    • 客户管理
      • 获取客户列表
      • 获取客户详情
      • 批量获取客户详情
      • 修改客户备注信息
      • 外部联系人unionid转换
      • 代开发应用external_userid转换
    • 客户标签管理
      • 管理企业标签
        • 获取企业标签库
        • 添加企业客户标签
        • 编辑企业客户标签
        • 删除企业客户标签
      • 编辑客户企业标签
    • 在职继承
      • 分配在职成员的客户
      • 查询客户接替状态
    • 离职继承
      • 获取待分配的离职成员列表
      • 分配离职成员的客户
      • 查询客户接替状态
      • 分配离职成员的客户群
    • 客户群管理
      • 获取客户群列表
      • 获取客户群详情
      • 客户群opengid转换
    • 客户朋友圈
      • 企业发表内容到客户的朋友圈
        • 创建发表任务
        • 获取任务创建结果
      • 获取客户朋友圈全部的发表记录
        • 获取企业全部的发表列表
        • 获取客户朋友圈企业发表的列表
        • 获取客户朋友圈发表时选择的可见范围
        • 获取客户朋友圈发表后的可见客户列表
        • 获取客户朋友圈的互动数据
    • 消息推送
      • 创建企业群发
      • 获取企业的全部群发记录
        • 获取群发记录列表
        • 获取群发成员发送任务列表
        • 获取企业群发成员执行结果
      • 发送新客户欢迎语
      • 入群欢迎语素材管理
    • 统计管理
      • 获取「联系客户统计」数据
      • 获取「群聊数据统计」数据
        • 按群主聚合的方式
        • 按自然日聚合的方式
    • 变更回调
      • 添加企业客户事件
      • 编辑企业客户事件
      • 外部联系人免验证添加成员事件
      • 删除企业客户事件
      • 删除跟进成员事件
      • 客户接替失败事件
      • 客户群创建事件
      • 客户群变更事件
      • 客户群解散事件
      • 企业客户标签创建事件
      • 企业客户标签变更事件
      • 企业客户标签删除事件
      • 企业客户标签重排事件
    • 管理商品图册
      • 创建商品图册
      • 获取商品图册
      • 获取商品图册列表
      • 编辑商品图册
      • 删除商品图册
    • 管理聊天敏感词
      • 新建敏感词规则
      • 获取敏感词规则列表
      • 获取敏感词规则详情
      • 修改敏感词规则
      • 删除敏感词规则
    • 上传附件资源
  • 微信客服
    • 客服帐号管理
      • 添加客服帐号
      • 删除客服帐号
      • 修改客服帐号
      • 获取客服帐号列表
      • 获取客服帐号连接
    • 接待人员管理
      • 添加接待人员
      • 删除接待人员
      • 获取接待人员列表
    • 会话分配与消息收发
      • 分配客服会话
      • 接收消息和事件
        • 读取消息
      • 发送消息
      • 发送欢迎语等事件响应消息
    • [升级服务]配置
    • 其它基础信息获取
      • 获取客户基础信息
      • 获取企业状态信息
    • 统计管理
      • 获取「客户数据统计」企业汇总数据
      • 获取「客户数据统计」接待人员明细数据
    • 机器人管理
      • 知识库分组管理
        • 添加分组
        • 删除分组
        • 修改分组
        • 获取分组列表
  • 接口调用许可
    • 订单管理
      • 下单购买帐号
      • 下单续期帐号
      • 获取订单列表
      • 获取订单详情
      • 获取订单中的帐号列表
    • 帐号管理
      • 激活帐号
      • 获取激活码详情
      • 获取企业的帐号列表
      • 获取成员的激活详情
      • 帐号继承
    • 自动激活设置
      • 设置企业的许可自动激活状态
      • 查询企业的许可自动激活状态
  • 应用管理
    • 获取应用
      • 获取指定的应用详情
      • 获取access_token对应的应用列表
    • 设置工作台自定义展示
  • 消息推送
    • 发送应用消息
    • 发送应用模板消息
    • 更新应用模板消息
    • 接收消息与事件
    • 撤回应用消息
  • 素材管理
    • 上传临时素材
    • 上传图片
    • 获取临时素材
    • 获取高清语音素材
  • 会话内容存档
    • 获取会话内容存档开启成员列表
    • 获取会话同意情况
    • 获取会话内容存档内部群信息
  • 电子发票
    • 查询电子发票
    • 更新发票状态
    • 批量更新发票状态
    • 批量查询电子发票
  • 学校沟通
    • 基础接口
      • 获取「学校通知」二维码
      • 管理「学校通知」的关注模式
        • 设置关注「学校通知」的模式
        • 获取关注「学校通知」的模式
      • 发送「学校通知」
      • 手机号转外部联系人ID
      • 管理「老师可查看班级」模式
        • 设置「老师可查看班级」的模式
        • 获取「老师可查看班级」的模式
      • 获取可使用的家长范围
    • 学生与家长管理
      • 创建学生
      • 删除学生
      • 更新学生
      • 批量创建学生
      • 批量删除学生
      • 批量更新学生
      • 创建家长
      • 删除家长
      • 更新家长
      • 批量创建家长
      • 批量删除家长
      • 批量更新家长
      • 读取学生或家长
      • 获取部门成员详情
      • 设置家校通讯录自动同步模式
      • 获取部门家长详情
    • 部门管理
      • 创建部门
      • 更新部门
      • 删除部门
      • 获取部门列表
      • 修改自动升年级的配置
  • 学校应用
    • 上课直播
      • 获取老师直播ID列表
      • 获取直播详情
      • 获取观看直播统计
      • 获取未观看直播统计
      • 删除直播回放
    • 班级收款
      • 获取学生付款结果
      • 获取订单详情

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Article
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ButtonSelection 按钮交互型.
No description provided by the author
No description provided by the author
No description provided by the author
CheckBox 投票选择型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
EmphasisContent 文本通知型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ImageTextArea 图文展示型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SelectList 多项选择型.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TODO: CardAction 必填(text_notice,news_notice)判断.
TemplateCardMessage 测试发送模板卡片消息必需配置应用回调地址.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Video 应用消息发关时title和description为可选项 朋友圈发送时只设置 media_id即可.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author