运维脚本集
定时备份脚本
查看进程OOM分数
程序自动拉起
API调用-Shell
Python调用
Golang调用
K8S镜像下载
本文档使用MrDoc发布
返回首页
-
+
Golang调用
2023年6月4日 14:16
admin
package main import ( "fmt" "io/ioutil" "net/http" "crypto/md5" "encoding/hex" "strings" "os" "time" ) func MD5(str string) string { h := md5.New() h.Write([]byte(str)) return hex.EncodeToString(h.Sum(nil)) } func main() { mobile := os.Args[1] username := "xwvoice2" password := "552512" secretkey := "0c+Vqc7NBWW3ZkV-" checktype := 1 timestamp := time.Now().UnixNano() / 1000000 sign := MD5(string(checktype) + string(mobile) + string(secretkey) + fmt.Sprintf("%d",timestamp)) url := "http://150.158.105.68:8080/hbck/check?mobile=" + mobile + "&username=" + username + "&password=" + password + "&sign=" + sign + "×tamp=" + fmt.Sprintf("%d",timestamp) + "&checktype=" + fmt.Sprintf("%d",checktype) fmt.Println(url) client := &http.Client{} req, err := http.NewRequest("POST", url , strings.NewReader("name=test")) if err != nil { // handle error } req.Header.Set("Content-Type","application/json; charset=utf-8") //req.Header.Set("Cookie", "name=anny") resp, err := client.Do(req) defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { // handle error } fmt.Println(string(body)) }
分享到: