package checkWx import ( "bytes" "context" "time" "91porn-server/common/httputil" "91porn-server/common/log" "91porn-server/common/stderr" ) const ApiToken string = "866mcJyA4teCehxivaCJec3qbghWStjA" type Resp struct { Code stderr.Code `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` } type CheckResp struct { Code stderr.Code `json:"code"` Msg string `json:"msg"` Data struct { Pass bool `json:"pass"` } `json:"data"` } // 获取订单信息 func CheckWx(execUrl, domian string) (checkResp CheckResp, err error) { c, cancle := context.WithTimeout(context.Background(), 5*time.Second) defer cancle() code, err := httputil.DefaultClientGetWithRespWithCtx(c, &checkResp, execUrl+"?"+bindUrl(domian), nil) log.Info("http method CheckWx response code ==>", log.Any("statusCode", code), log.Any("checkResp", checkResp)) if err != nil { log.Error("CheckWx failed", log.E(err)) } return } func TgSend(msgPayload, text string) (resp Resp, err error) { params := map[string]interface{}{ "tgName": "ys_bot", "text": text, "msgPayload": msgPayload, "chatId": -228259065, } c, cancle := context.WithTimeout(context.Background(), 5*time.Second) defer cancle() code, err := httputil.DefaultClientPostJsonWithRespWithCtx(c, &resp, "http://uni.ztgba.com/api/tg/send", nil, params) log.Info("http method TgSend response code ==>", log.Any("statusCode", code), log.Any("resp", resp)) if err != nil { log.Error("TgSend failed", log.E(err)) } return } func bindUrl(domain string) string { buf := bytes.Buffer{} buf.WriteString("apiToken=") buf.WriteString(ApiToken + "&") buf.WriteString("req_url=") buf.WriteString(domain) return buf.String() }