mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-06 21:52:27 +08:00
企业微信新增接口:素材管理、企业群发 (#620)
* 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * 企业微信-客户联系-统计管理 * debug * rollback * debug * debug * 获取用户信息 * token * json.Marshal错误输出 * debug * bugfix * 企业微信-通讯录管理相关接口 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-通讯录管理 * 企业微信-[联系我]方式新增和查询 * 企业微信-[联系我]方式新增和获取 * 企业微信-[联系我]方式更新 * 企业微信-[联系我]方式列表、删除 * json.Marshal错误输出 * 已实现接口bug修改 * 历史接口bugfix * 历史接口bugfix * comment * 企业微信:客户联系-消息推送;素材管理-上传图片 * fix Co-authored-by: wang.yu <wangyu@uniondrug.com>
This commit is contained in:
17
work/material/client.go
Normal file
17
work/material/client.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
"github.com/silenceper/wechat/v2/work/context"
|
||||
)
|
||||
|
||||
// Client 素材管理接口实例
|
||||
type Client struct {
|
||||
*context.Context
|
||||
}
|
||||
|
||||
// NewClient 初始化实例
|
||||
func NewClient(ctx *context.Context) *Client {
|
||||
return &Client{
|
||||
ctx,
|
||||
}
|
||||
}
|
||||
39
work/material/media.go
Normal file
39
work/material/media.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/silenceper/wechat/v2/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// UploadImgURL 上传图片
|
||||
UploadImgURL = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token=%s"
|
||||
)
|
||||
|
||||
// UploadImgResponse 上传图片响应
|
||||
type UploadImgResponse struct {
|
||||
util.CommonError
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// UploadImg 上传图片
|
||||
// @see https://developer.work.weixin.qq.com/document/path/90256
|
||||
func (r *Client) UploadImg(filename string) (*UploadImgResponse, error) {
|
||||
var (
|
||||
accessToken string
|
||||
err error
|
||||
)
|
||||
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var response []byte
|
||||
if response, err = util.PostFile("media", filename, fmt.Sprintf(UploadImgURL, accessToken)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &UploadImgResponse{}
|
||||
if err = util.DecodeWithError(response, result, "UploadImg"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user