代码拉取完成,页面将自动刷新
package qywechat
import (
"encoding/json"
"fmt"
"gitee.com/dtapps/go-qywechat/qywechat/message"
"io/ioutil"
"net/http"
"strings"
)
const api = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
type QyBot struct {
Key string
}
type response struct {
Errcode int64 `json:"errcode"`
Errmsg string `json:"errmsg"`
Type string `json:"type"`
MediaId string `json:"media_id"`
CreatedAt string `json:"created_at"`
}
func (bot *QyBot) Send(msg message.Message) (response, error) {
var response response
qyUrl := fmt.Sprintf("%s?key=%s", api, bot.Key)
j, e := json.Marshal(msg)
if e != nil {
return response, e
}
resp, e := http.Post(qyUrl, "application/json", strings.NewReader(string(j)))
if e != nil {
return response, e
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
e = json.Unmarshal(body, &response)
if e != nil {
return response, e
}
return response, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。