企业微信第三方应用|自建代开发|自建应用 三合一 sdk golang版;支持服务商应用运营体系
版本变更日志参见 CHANGELOG.md
更多相关文章将会在公众号分享,欢迎关注!
http请求改用go-resty
可方便指定重试、错误处理hooks(当前未处理)
go get github.com/go-laoji/wecom-go-sdk/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