webhook.go
func (w *Webhook) SendPayload(payload *Payload) error {
	bs, err := json.Marshal(payload)
	if err != nil {
		return err
	}

	resp, err := http.Post("https://oapi.dingtalk.com/robot/send?access_token="+w.accessToken, "application/json", bytes.NewReader(bs))
	if err != nil {
		return err
	}

	bs, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}

	if resp.StatusCode != 200 {
		return fmt.Errorf("%d: %s", resp.StatusCode, string(bs))
	}

	var result Response
	err = json.Unmarshal(bs, &result)
	if err != nil {
		return err
	}
	if result.ErrorCode != 0 {
		return fmt.Errorf("%d: %s", result.ErrorCode, result.ErrorMessage)
	}

	return nil
}
func (w *Webhook) SendPayload(payload *Payload) error {
	bs, err := json.Marshal(payload)
	if err != nil {
		return err
	}

	resp, err := http.Post("https://oapi.dingtalk.com/robot/send?access_token="+w.accessToken, "application/json", bytes.NewReader(bs))
	if err != nil {
		return err
	}

	bs, err = ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}

	if resp.StatusCode != 200 {
		return fmt.Errorf("%d: %s", resp.StatusCode, string(bs))
	}

	var result Response
	err = json.Unmarshal(bs, &result)
	if err != nil {
		return err
	}
	if result.ErrorCode != 0 {
		return fmt.Errorf("%d: %s", result.ErrorCode, result.ErrorMessage)
	}

	return nil
}
// SendPayload 发送消息