标签:ati buffer interface print ons ken int url util
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
const webhook_url = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
func dingToInfo(s string) bool {
content, data := make(map[string]string), make(map[string]interface{})
content["content"] = s
data["msgtype"] = "text"
data["text"] = content
b, _ := json.Marshal(data)
resp, err := http.Post(webhook_url,
"application/json",
bytes.NewBuffer(b))
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
return true
}
func main() {
dingToInfo("报警")
}
标签:ati buffer interface print ons ken int url util
原文地址:https://blog.51cto.com/hequan/2374161