xdd-plus/models/pushplus.go

31 lines
642 B
Go
Raw Normal View History

2021-08-15 09:48:05 +08:00
package models
import (
"encoding/json"
"github.com/beego/beego/v2/client/httplib"
)
func pushPlus(token string, content string) {
2021-08-19 09:38:44 +08:00
if token == "" {
return
}
2021-08-15 09:48:05 +08:00
data, _ := json.Marshal(struct {
2021-08-19 11:17:37 +08:00
Token string `json:"token"`
Content string `json:"content"`
Template string `json:"template"`
2021-08-15 09:48:05 +08:00
}{
2021-08-19 11:17:37 +08:00
Token: token,
Content: content,
Template: "txt",
2021-08-15 09:48:05 +08:00
})
2021-08-19 11:17:37 +08:00
req := httplib.Post("http://pushplus.hxtrip.com/send")
req.Header("Content-Type", "application/json")
2021-08-15 09:48:05 +08:00
req.Body(data)
req.Response()
2021-08-19 11:14:15 +08:00
req = httplib.Post("http://www.pushplus.plus/send")
req.Header("Content-Type", "application/json")
req.Body(data)
req.Response()
2021-08-15 09:48:05 +08:00
}