Send 发送应用消息 @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90248
(apiName string, request interface{})
| 65 | // Send 发送应用消息 |
| 66 | // @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90248 |
| 67 | func (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 发送文本消息 |
| 91 | func (r *Client) SendText(request SendTextRequest) (*SendResponse, error) { |
no test coverage detected