Browse Source

体积小

XMLWAN 2 years ago
parent
commit
b6e7994d9c

+ 2 - 1
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go View File

1051
 	var appid = "wxcdf53b48b7df107e"
1051
 	var appid = "wxcdf53b48b7df107e"
1052
 	var secret = "94e944a69ad1d43ac447f5a8769ab801"
1052
 	var secret = "94e944a69ad1d43ac447f5a8769ab801"
1053
 	var grant_type = "authorization_code"
1053
 	var grant_type = "authorization_code"
1054
-	code := this.GetString("js_code")
1054
+	//code := this.GetString("js_code")
1055
+	var code = "061Vw9Ga18vxSB0KvZIa1dDoGE2Vw9G6"
1055
 
1056
 
1056
 	openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
1057
 	openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
1057
 	session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)
1058
 	session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)

+ 4 - 21
service/xcx_mobile_api_service.go View File

634
 	return score, total, err
634
 	return score, total, err
635
 }
635
 }
636
 
636
 
637
-//func GetOpenId(appid string,secret string,grant_type string,code string)(string, error)
638
-//
639
-//  var code2sessionURL = "https://xcx.kuyicloud.com/xcx/api/mobile/getappid?appid="
640
-//
641
-//  url := fmt.Sprintf(code2sessionURL, appID, appSecret, code)
642
-//  resp, err := http.DefaultClient.Get(url)
643
-//  if err != nil {
644
-//  return "", err
645
-//  }
646
-//  var wxMap map[string]string
647
-//  err = json.NewDecoder(resp.Body).Decode(&wxMap)
648
-//  if err != nil {
649
-//  return "", err
650
-//  }
651
-//  defer resp.Body.Close()
652
-//
653
-//  return wxMap["openid"], nil
654
-//}
655
-
656
 func SendWxAuthAPI(appID string, appSecret string, grant_type string, code string) (string, error) {
637
 func SendWxAuthAPI(appID string, appSecret string, grant_type string, code string) (string, error) {
657
-	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
638
+
639
+	var code2sessionURL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appID + "&secret=" + appSecret + "&code=" + code + "&grant_type=" + grant_type
658
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
640
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
659
 	fmt.Println("url233232323322323", url)
641
 	fmt.Println("url233232323322323", url)
660
 	resp, err := http.DefaultClient.Get(url)
642
 	resp, err := http.DefaultClient.Get(url)
643
+	fmt.Println("resp32332232332322", resp)
661
 	if err != nil {
644
 	if err != nil {
662
 		return "", err
645
 		return "", err
663
 	}
646
 	}
672
 }
655
 }
673
 
656
 
674
 func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
657
 func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
675
-	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
658
+	var code2sessionURL = "GET https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
676
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
659
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
677
 	fmt.Println("url233232323322323", url)
660
 	fmt.Println("url233232323322323", url)
678
 	resp, err := http.DefaultClient.Get(url)
661
 	resp, err := http.DefaultClient.Get(url)