mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-15 18:22:26 +08:00
Compare commits
3 Commits
5380d5bee7
...
v2.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243f8198ae | ||
|
|
2bc0536c02 | ||
|
|
bbbada1b44 |
@@ -73,6 +73,7 @@ host: https://qyapi.weixin.qq.com/
|
|||||||
| 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG |
|
| 获取企业已配置的「联系我」列表 | POST | /cgi-bin/externalcontact/list_contact_way | YES | (r *Client) ListContactWay | MARKWANG |
|
||||||
| 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG |
|
| 删除企业已配置的「联系我」方式 | POST | /cgi-bin/externalcontact/del_contact_way | YES | (r *Client) DelContactWay | MARKWANG |
|
||||||
| 创建企业群发 | POST | /cgi-bin/externalcontact/add_msg_template | YES | (r *Client) AddMsgTemplate | MARKWANG |
|
| 创建企业群发 | POST | /cgi-bin/externalcontact/add_msg_template | YES | (r *Client) AddMsgTemplate | MARKWANG |
|
||||||
|
| 获取群发记录列表 | POST | /cgi-bin/externalcontact/get_groupmsg_list_v2 | YES | (r *Client) GetGroupMsgListV2 | MARKWANG |
|
||||||
| 获取群发成员发送任务列表 | POST | /cgi-bin/externalcontact/get_groupmsg_task | YES | (r *Client) GetGroupMsgTask | MARKWANG |
|
| 获取群发成员发送任务列表 | POST | /cgi-bin/externalcontact/get_groupmsg_task | YES | (r *Client) GetGroupMsgTask | MARKWANG |
|
||||||
| 获取企业群发成员执行结果 | POST | /cgi-bin/externalcontact/get_groupmsg_send_result | YES | (r *Client) GetGroupMsgSendResult | MARKWANG |
|
| 获取企业群发成员执行结果 | POST | /cgi-bin/externalcontact/get_groupmsg_send_result | YES | (r *Client) GetGroupMsgSendResult | MARKWANG |
|
||||||
| 发送新客户欢迎语 | POST | /cgi-bin/externalcontact/send_welcome_msg | YES | (r *Client) SendWelcomeMsg | MARKWANG |
|
| 发送新客户欢迎语 | POST | /cgi-bin/externalcontact/send_welcome_msg | YES | (r *Client) SendWelcomeMsg | MARKWANG |
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package miniprogram
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/silenceper/wechat/v2/credential"
|
||||||
|
"github.com/silenceper/wechat/v2/miniprogram"
|
||||||
|
miniConfig "github.com/silenceper/wechat/v2/miniprogram/config"
|
||||||
miniContext "github.com/silenceper/wechat/v2/miniprogram/context"
|
miniContext "github.com/silenceper/wechat/v2/miniprogram/context"
|
||||||
"github.com/silenceper/wechat/v2/miniprogram/urllink"
|
"github.com/silenceper/wechat/v2/miniprogram/urllink"
|
||||||
openContext "github.com/silenceper/wechat/v2/openplatform/context"
|
openContext "github.com/silenceper/wechat/v2/openplatform/context"
|
||||||
@@ -14,7 +17,7 @@ import (
|
|||||||
type MiniProgram struct {
|
type MiniProgram struct {
|
||||||
AppID string
|
AppID string
|
||||||
openContext *openContext.Context
|
openContext *openContext.Context
|
||||||
|
*miniprogram.MiniProgram
|
||||||
authorizerRefreshToken string
|
authorizerRefreshToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,10 +45,13 @@ func (miniProgram *MiniProgram) SetAuthorizerRefreshToken(authorizerRefreshToken
|
|||||||
|
|
||||||
// NewMiniProgram 实例化
|
// NewMiniProgram 实例化
|
||||||
func NewMiniProgram(opCtx *openContext.Context, appID string) *MiniProgram {
|
func NewMiniProgram(opCtx *openContext.Context, appID string) *MiniProgram {
|
||||||
return &MiniProgram{
|
miniProgram := miniprogram.NewMiniProgram(&miniConfig.Config{
|
||||||
openContext: opCtx,
|
AppID: opCtx.AppID,
|
||||||
AppID: appID,
|
Cache: opCtx.Cache,
|
||||||
}
|
})
|
||||||
|
// 设置获取access_token的函数
|
||||||
|
miniProgram.SetAccessTokenHandle(NewDefaultAuthrAccessToken(opCtx, appID))
|
||||||
|
return &MiniProgram{AppID: appID, MiniProgram: miniProgram, openContext: opCtx}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetComponent get component
|
// GetComponent get component
|
||||||
@@ -65,3 +71,22 @@ func (miniProgram *MiniProgram) GetURLLink() *urllink.URLLink {
|
|||||||
AccessTokenHandle: miniProgram,
|
AccessTokenHandle: miniProgram,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultAuthrAccessToken 默认获取授权ak的方法
|
||||||
|
type DefaultAuthrAccessToken struct {
|
||||||
|
opCtx *openContext.Context
|
||||||
|
appID string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDefaultAuthrAccessToken 设置access_token
|
||||||
|
func NewDefaultAuthrAccessToken(opCtx *openContext.Context, appID string) credential.AccessTokenHandle {
|
||||||
|
return &DefaultAuthrAccessToken{
|
||||||
|
opCtx: opCtx,
|
||||||
|
appID: appID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAccessToken 获取ak
|
||||||
|
func (ak *DefaultAuthrAccessToken) GetAccessToken() (string, error) {
|
||||||
|
return ak.opCtx.GetAuthrAccessToken(ak.appID)
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,7 +47,9 @@ func (r *Client) GetExternalUserList(userID string) ([]string, error) {
|
|||||||
// ExternalUserDetailResponse 外部联系人详情响应
|
// ExternalUserDetailResponse 外部联系人详情响应
|
||||||
type ExternalUserDetailResponse struct {
|
type ExternalUserDetailResponse struct {
|
||||||
util.CommonError
|
util.CommonError
|
||||||
ExternalUser
|
ExternalContact ExternalUser `json:"external_contact"`
|
||||||
|
FollowUser []FollowUser `json:"follow_user"`
|
||||||
|
NextCursor string `json:"next_cursor"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExternalUser 外部联系人
|
// ExternalUser 外部联系人
|
||||||
@@ -62,8 +64,6 @@ type ExternalUser struct {
|
|||||||
CorpName string `json:"corp_name"`
|
CorpName string `json:"corp_name"`
|
||||||
CorpFullName string `json:"corp_full_name"`
|
CorpFullName string `json:"corp_full_name"`
|
||||||
ExternalProfile string `json:"external_profile"`
|
ExternalProfile string `json:"external_profile"`
|
||||||
FollowUser []FollowUser `json:"follow_user"`
|
|
||||||
NextCursor string `json:"next_cursor"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FollowUser 跟进用户(指企业内部用户)
|
// FollowUser 跟进用户(指企业内部用户)
|
||||||
@@ -96,7 +96,8 @@ type WechatChannel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetExternalUserDetail 获取外部联系人详情
|
// GetExternalUserDetail 获取外部联系人详情
|
||||||
func (r *Client) GetExternalUserDetail(externalUserID string, nextCursor ...string) (*ExternalUser, error) {
|
// @see https://developer.work.weixin.qq.com/document/path/92114
|
||||||
|
func (r *Client) GetExternalUserDetail(externalUserID string, nextCursor ...string) (*ExternalUserDetailResponse, error) {
|
||||||
accessToken, err := r.GetAccessToken()
|
accessToken, err := r.GetAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -106,12 +107,12 @@ func (r *Client) GetExternalUserDetail(externalUserID string, nextCursor ...stri
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var result ExternalUserDetailResponse
|
result := &ExternalUserDetailResponse{}
|
||||||
err = util.DecodeWithError(response, &result, "get_external_user_detail")
|
err = util.DecodeWithError(response, result, "get_external_user_detail")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &result.ExternalUser, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BatchGetExternalUserDetailsRequest 批量获取外部联系人详情请求
|
// BatchGetExternalUserDetailsRequest 批量获取外部联系人详情请求
|
||||||
@@ -161,6 +162,7 @@ type FollowInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BatchGetExternalUserDetails 批量获取外部联系人详情
|
// BatchGetExternalUserDetails 批量获取外部联系人详情
|
||||||
|
// @see https://developer.work.weixin.qq.com/document/path/92994
|
||||||
func (r *Client) BatchGetExternalUserDetails(request BatchGetExternalUserDetailsRequest) ([]ExternalUserForBatch, error) {
|
func (r *Client) BatchGetExternalUserDetails(request BatchGetExternalUserDetailsRequest) ([]ExternalUserForBatch, error) {
|
||||||
accessToken, err := r.GetAccessToken()
|
accessToken, err := r.GetAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -195,6 +197,7 @@ type UpdateUserRemarkRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateUserRemark 修改客户备注信息
|
// UpdateUserRemark 修改客户备注信息
|
||||||
|
// @see https://developer.work.weixin.qq.com/document/path/92115
|
||||||
func (r *Client) UpdateUserRemark(request UpdateUserRemarkRequest) error {
|
func (r *Client) UpdateUserRemark(request UpdateUserRemarkRequest) error {
|
||||||
accessToken, err := r.GetAccessToken()
|
accessToken, err := r.GetAccessToken()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import (
|
|||||||
const (
|
const (
|
||||||
// AddMsgTemplateURL 创建企业群发
|
// AddMsgTemplateURL 创建企业群发
|
||||||
AddMsgTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=%s"
|
AddMsgTemplateURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=%s"
|
||||||
|
// GetGroupMsgListV2URL 获取群发记录列表
|
||||||
|
GetGroupMsgListV2URL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_list_v2?access_token=%s"
|
||||||
// GetGroupMsgTaskURL 获取群发成员发送任务列表
|
// GetGroupMsgTaskURL 获取群发成员发送任务列表
|
||||||
GetGroupMsgTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_task?access_token=%s"
|
GetGroupMsgTaskURL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_task?access_token=%s"
|
||||||
// GetGroupMsgSendResultURL 获取企业群发成员执行结果
|
// GetGroupMsgSendResultURL 获取企业群发成员执行结果
|
||||||
@@ -98,6 +100,55 @@ func (r *Client) AddMsgTemplate(req *AddMsgTemplateRequest) (*AddMsgTemplateResp
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetGroupMsgListV2Request 获取群发记录列表请求
|
||||||
|
type GetGroupMsgListV2Request struct {
|
||||||
|
ChatType string `json:"chat_type"`
|
||||||
|
StartTime int `json:"start_time"`
|
||||||
|
EndTime int `json:"end_time"`
|
||||||
|
Creator string `json:"creator,omitempty"`
|
||||||
|
FilterType int `json:"filter_type"`
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
Cursor string `json:"cursor"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroupMsgListV2Response 获取群发记录列表响应
|
||||||
|
type GetGroupMsgListV2Response struct {
|
||||||
|
util.CommonError
|
||||||
|
NextCursor string `json:"next_cursor"`
|
||||||
|
GroupMsgList []*GroupMsg `json:"group_msg_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupMsg 群发消息
|
||||||
|
type GroupMsg struct {
|
||||||
|
MsgID string `json:"msgid"`
|
||||||
|
Creator string `json:"creator"`
|
||||||
|
CreateTime int `json:"create_time"`
|
||||||
|
CreateType int `json:"create_type"`
|
||||||
|
Text MsgText `json:"text"`
|
||||||
|
Attachments []*Attachment `json:"attachments"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroupMsgListV2 获取群发记录列表
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%8F%91%E8%AE%B0%E5%BD%95%E5%88%97%E8%A1%A8
|
||||||
|
func (r *Client) GetGroupMsgListV2(req *GetGroupMsgListV2Request) (*GetGroupMsgListV2Response, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(GetGroupMsgListV2URL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetGroupMsgListV2Response{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetGroupMsgListV2"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetGroupMsgTaskRequest 获取群发成员发送任务列表请求
|
// GetGroupMsgTaskRequest 获取群发成员发送任务列表请求
|
||||||
type GetGroupMsgTaskRequest struct {
|
type GetGroupMsgTaskRequest struct {
|
||||||
MsgID string `json:"msgid"`
|
MsgID string `json:"msgid"`
|
||||||
@@ -120,7 +171,7 @@ type Task struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetGroupMsgTask 获取群发成员发送任务列表
|
// GetGroupMsgTask 获取群发成员发送任务列表
|
||||||
// see https://developer.work.weixin.qq.com/document/path/93338
|
// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E7%BE%A4%E5%8F%91%E6%88%90%E5%91%98%E5%8F%91%E9%80%81%E4%BB%BB%E5%8A%A1%E5%88%97%E8%A1%A8
|
||||||
func (r *Client) GetGroupMsgTask(req *GetGroupMsgTaskRequest) (*GetGroupMsgTaskResponse, error) {
|
func (r *Client) GetGroupMsgTask(req *GetGroupMsgTaskRequest) (*GetGroupMsgTaskResponse, error) {
|
||||||
var (
|
var (
|
||||||
accessToken string
|
accessToken string
|
||||||
@@ -165,7 +216,7 @@ type Send struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetGroupMsgSendResult 获取企业群发成员执行结果
|
// GetGroupMsgSendResult 获取企业群发成员执行结果
|
||||||
// see https://developer.work.weixin.qq.com/document/path/93338
|
// see https://developer.work.weixin.qq.com/document/path/93338#%E8%8E%B7%E5%8F%96%E4%BC%81%E4%B8%9A%E7%BE%A4%E5%8F%91%E6%88%90%E5%91%98%E6%89%A7%E8%A1%8C%E7%BB%93%E6%9E%9C
|
||||||
func (r *Client) GetGroupMsgSendResult(req *GetGroupMsgSendResultRequest) (*GetGroupMsgSendResultResponse, error) {
|
func (r *Client) GetGroupMsgSendResult(req *GetGroupMsgSendResultRequest) (*GetGroupMsgSendResultResponse, error) {
|
||||||
var (
|
var (
|
||||||
accessToken string
|
accessToken string
|
||||||
|
|||||||
Reference in New Issue
Block a user