MCPcopy
hub / github.com/silenceper/wechat / Send

Method Send

work/appchat/appchat.go:67–88  ·  view source on GitHub ↗

Send 发送应用消息 @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90248

(apiName string, request interface{})

Source from the content-addressed store, hash-verified

65// Send 发送应用消息
66// @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90248
67func (r *Client) Send(apiName string, request interface{}) (*SendResponse, error) {
68 // 获取accessToken
69 accessToken, err := r.GetAccessToken()
70 if err != nil {
71 return nil, err
72 }
73 // 请求参数转 JSON 格式
74 jsonData, err := json.Marshal(request)
75 if err != nil {
76 return nil, err
77 }
78 // 发起http请求
79 response, err := util.HTTPPost(fmt.Sprintf(sendURL, accessToken), string(jsonData))
80 if err != nil {
81 return nil, err
82 }
83 // 按照结构体解析返回值
84 result := &SendResponse{}
85 err = util.DecodeWithError(response, result, apiName)
86 // 返回数据
87 return result, err
88}
89
90// SendText 发送文本消息
91func (r *Client) SendText(request SendTextRequest) (*SendResponse, error) {

Callers 3

SendTextMethod · 0.95
SendImageMethod · 0.95
SendVoiceMethod · 0.95

Calls 3

HTTPPostFunction · 0.92
DecodeWithErrorFunction · 0.92
GetAccessTokenMethod · 0.65

Tested by

no test coverage detected