|
|
|
@ -572,7 +572,7 @@ func wxLogin(context *gin.Context) {
|
|
|
|
|
var code = context.PostForm("code")
|
|
|
|
|
//对接微信,腾讯给的AK+SK
|
|
|
|
|
appId := "wx3e0449144386938a"
|
|
|
|
|
appSecret := "15a37979f34791ca8b920c386afaa0d5"
|
|
|
|
|
appSecret := "5175be38ddd689d1621df35cc22c192b"
|
|
|
|
|
//验证的地址
|
|
|
|
|
var accessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token"
|
|
|
|
|
var accessTokenParams = fmt.Sprintf("appid=%s&secret=%s&code=%s&grant_type=authorization_code", appId, appSecret, code)
|
|
|
|
@ -586,8 +586,12 @@ func wxLogin(context *gin.Context) {
|
|
|
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
|
|
if resp.StatusCode == 200 {
|
|
|
|
|
//将返回结果转为json
|
|
|
|
|
openid := gjson.Get(string(body), "openid")
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": true, "openid": openid})
|
|
|
|
|
result := gjson.Get(string(body), "openid")
|
|
|
|
|
if len(result.Str) == 0 {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "openid": ""})
|
|
|
|
|
} else {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": true, "openid": result.Str})
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "openid": ""})
|
|
|
|
|
}
|
|
|
|
|