87 lines
1.9 KiB
Go
87 lines
1.9 KiB
Go
package app
|
|
|
|
import (
|
|
. "../../../hotime"
|
|
. "../../../hotime/common"
|
|
"bytes"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
var ID = "aad1472b19e575a71ee8f75629e27867"
|
|
|
|
// Project 管理端项目
|
|
var Project = Proj{
|
|
//"user": UserCtr,
|
|
"category": categoryCtr,
|
|
"ctg_order_date": ctg_order_dateCtr,
|
|
"order": orderCtr,
|
|
"user": userCtr,
|
|
"sms": Sms,
|
|
}
|
|
|
|
//生成随机码的4位随机数
|
|
func getCode() string {
|
|
//res := ""
|
|
//for i := 0; i < 4; i++ {
|
|
res := ObjToStr(RandX(1000, 9999))
|
|
//}
|
|
return res
|
|
}
|
|
|
|
func tencentSendYzm(umobile, code string) error {
|
|
|
|
random := RandX(999999, 9999999)
|
|
url := "https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400235813&random=" + ObjToStr(random)
|
|
fmt.Println("URL:>", url)
|
|
|
|
h := sha256.New()
|
|
h.Write([]byte(`appkey=d511de15e5ccb43fc171772dbb8b599f&random=` + ObjToStr(random) + `&time=` + ObjToStr(time.Now().Unix()) + `&mobile=` + umobile))
|
|
bs := h.Sum(nil)
|
|
s256 := hex.EncodeToString(bs)
|
|
|
|
//json序列化
|
|
post := `{
|
|
"ext": "",
|
|
"extend": "",
|
|
"params": [
|
|
"` + code + `"
|
|
],
|
|
"sig": "` + s256 + `",
|
|
"sign": "乐呵呵旅游网",
|
|
"tel": {
|
|
"mobile": "` + umobile + `",
|
|
"nationcode": "86"
|
|
},
|
|
"time": ` + ObjToStr(time.Now().Unix()) + `,
|
|
"tpl_id": 378916
|
|
}`
|
|
|
|
fmt.Println(url, "post", post)
|
|
|
|
var jsonStr = []byte(post)
|
|
fmt.Println("jsonStr", jsonStr)
|
|
fmt.Println("new_str", bytes.NewBuffer(jsonStr))
|
|
|
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
|
|
// req.Header.Set("X-Custom-Header", "myvalue")
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
client := &http.Client{}
|
|
resp, err := client.Do(req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
fmt.Println("response Status:", resp.Status)
|
|
fmt.Println("response Headers:", resp.Header)
|
|
body, _ := ioutil.ReadAll(resp.Body)
|
|
fmt.Println("response Body:", string(body))
|
|
return nil
|
|
}
|