map panic issue

master
dustoair 3 years ago
parent 3b2b97f860
commit c19acca0cc

@ -3,6 +3,7 @@ package main
import (
"WechatGateWay/global"
"WechatGateWay/handle"
"WechatGateWay/third_part"
"fmt"
"github.com/spf13/viper"
"log"
@ -28,7 +29,7 @@ func init() {
global.WechatSendAid = viper.GetString("wechat.SendAid")
// receive_id 企业应用的回调表示corpid
global.WxCrypt = global.NewWXBizMsgCrypt(global.WechatToken, global.WechatEncodingAesKey, global.WechatCorpId, global.XmlType)
//go third_part.GetRemoteToken(global.WechatCorpId, global.WechatSendSecret)
third_part.GetRemoteToken(global.WechatCorpId, global.WechatSendSecret)
log.Println("server init success")
}
func main() {

@ -50,13 +50,17 @@ func GetRemoteToken(corpId, appSecret string) string {
}
resp.Body.Close()
tokenResponse := utils.ParseJson(string(respData))
//log.Println("企业微信获取access_token接口返回==>", tokenResponse)
accessToken := tokenResponse["access_token"].(string)
var accessToken string
_, ok := tokenResponse["access_token"]
if ok {
accessToken = fmt.Sprintf("%s", tokenResponse["access_token"])
//存到gloabl
global.WechatAccessToken = accessToken
log.Println("WechatAccessToken已更新")
}
return accessToken
}
// PostMsg 推送消息

Loading…
Cancel
Save