fixed
This commit is contained in:
parent
829259f72f
commit
865cf44cd1
|
|
@ -9,7 +9,7 @@
|
|||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "E://dingd"
|
||||
"program": "C://Users//lenovo//Desktop//gogin//dingding"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
main.go
16
main.go
|
|
@ -21,12 +21,6 @@ import (
|
|||
"myschools.me/wyh/dingd.git/model"
|
||||
)
|
||||
|
||||
const (
|
||||
AuthCode = "bdbc74ebecaf30259895b145d3c48d35"
|
||||
Appkey = "dinguipztmzpv8sog933"
|
||||
AppSecret = "kUYbKHxNixdMhTmW6IrdTE-yVnWfQLs1C7RQIAsrlwz8BYlVmceFs-3JRBmU32rQ"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cf := flag.String("config", "config.yaml", "file of config")
|
||||
flag.Parse()
|
||||
|
|
@ -37,13 +31,13 @@ func main() {
|
|||
}).Errorf("%s", err.Error())
|
||||
return
|
||||
}
|
||||
timestamp := strconv.FormatInt(time.Now().UnixNano()/1000000, 10) // 毫秒时间戳
|
||||
signature := EncodeSHA256(timestamp, AppSecret) // 加密签名 加密算法见我另一个函数
|
||||
timestamp := strconv.FormatInt(time.Now().UnixNano()/1000000, 10) // 毫秒时间戳
|
||||
signature := EncodeSHA256(timestamp, viper.GetString("app.AppSecret")) // 加密签名 加密算法见我另一个函数
|
||||
url := fmt.Sprintf("https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey=%s×tamp=%s&signature=%s",
|
||||
Appkey, timestamp, signature)
|
||||
viper.GetString("app.AppKey"), timestamp, signature)
|
||||
p := struct {
|
||||
Tmp_auth_code string `json:"tmp_auth_code"`
|
||||
}{AuthCode} // post数据
|
||||
}{viper.GetString("app.AuthCode")} // post数据
|
||||
p1, _ := json.Marshal(p)
|
||||
p2 := string(p1)
|
||||
p3 := strings.NewReader(p2) //构建post数据
|
||||
|
|
@ -96,7 +90,7 @@ func GetAccesstoken() (accesstoken string, err error) {
|
|||
var resp *http.Response
|
||||
//var AppKey, AppSecret string
|
||||
//获取access_token
|
||||
url := fmt.Sprintf("https://oapi.dingtalk.com/gettoken?appkey=%s&appsecret=%s", Appkey, AppSecret)
|
||||
url := fmt.Sprintf("https://oapi.dingtalk.com/gettoken?appkey=%s&appsecret=%s", viper.GetString("app.AppKey"), viper.GetString("app.AppSecret"))
|
||||
resp, err = http.Get(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
Loading…
Reference in New Issue