You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
57 lines
1.5 KiB
|
4 years ago
|
package commonus
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"fmt"
|
||
|
|
)
|
||
|
|
|
||
|
|
//设定信息发送地址
|
||
|
|
func sendUrlSet() (sendUrlstr string, isTrue bool, msg string) {
|
||
|
|
isTrue = false
|
||
|
|
ton, _, err := GetWechatTokenType("")
|
||
|
|
if err != nil {
|
||
|
|
msg = "获取ToKen失败!"
|
||
|
|
return
|
||
|
|
}
|
||
|
|
isTrue = true
|
||
|
|
msg = "获取ToKen成功!"
|
||
|
|
sendUrlstr = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + ton
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
//发送文本信息
|
||
|
4 years ago
|
func (t *SendText) SendTextMessage() ([]byte, bool, string) {
|
||
|
4 years ago
|
sendUrl, IsTrue, msg := sendUrlSet()
|
||
|
|
if IsTrue == false {
|
||
|
4 years ago
|
return nil, false, msg
|
||
|
4 years ago
|
}
|
||
|
|
sendJsonData, _ := json.Marshal(t)
|
||
|
|
addDePartMent := CurlPostJosn(sendUrl, sendJsonData)
|
||
|
4 years ago
|
// fmt.Printf("%v-------------->%v\n", string(sendJsonData), string(addDePartMent))
|
||
|
|
return addDePartMent, true, msg
|
||
|
4 years ago
|
}
|
||
|
|
|
||
|
|
//发送文本信息
|
||
|
|
func (s *SendMarkDown) SendMarkDownMassage() (bool, string) {
|
||
|
|
sendUrl, IsTrue, msg := sendUrlSet()
|
||
|
|
if IsTrue == false {
|
||
|
|
return false, msg
|
||
|
|
}
|
||
|
|
sendJsonData, _ := json.Marshal(s)
|
||
|
|
addDePartMent := CurlPostJosn(sendUrl, sendJsonData)
|
||
|
|
fmt.Printf("%v-------------->%v\n", string(sendJsonData), string(addDePartMent))
|
||
|
|
return true, msg
|
||
|
|
}
|
||
|
4 years ago
|
|
||
|
|
//发送图文信息
|
||
|
|
func (s *SendImgCont) SendImgMessage() ([]byte, bool, string) {
|
||
|
|
sendUrl, IsTrue, msg := sendUrlSet()
|
||
|
|
if IsTrue == false {
|
||
|
|
return nil, false, msg
|
||
|
|
}
|
||
|
|
sendJsonData, _ := json.Marshal(s)
|
||
|
|
addDePartMent := CurlPostJosn(sendUrl, sendJsonData)
|
||
|
|
// fmt.Printf("%v-------------->%v\n", string(sendJsonData), string(addDePartMent))
|
||
|
|
return addDePartMent, true, msg
|
||
|
|
}
|