Browse Source

体积小

XMLWAN 3 years ago
parent
commit
ac61adbe5b

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

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

+ 6 - 7
service/xcx_mobile_api_service.go View File

@@ -634,29 +634,28 @@ func GetStoryScoreList(activityID int64, page int64, limit int64) (score []*mode
634 634
 	return score, total, err
635 635
 }
636 636
 
637
-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) (map[string]string, error) {
638 638
 
639 639
 	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
640 640
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
641 641
 	fmt.Println("url233232323322323", url)
642 642
 	resp, err := http.DefaultClient.Get(code2sessionURL)
643 643
 	fmt.Println("resp32332232332322", resp)
644
-	if err != nil {
645
-		return "", err
646
-	}
644
+
647 645
 	var wxMap map[string]string
648 646
 	err = json.NewDecoder(resp.Body).Decode(&wxMap)
649 647
 	if err != nil {
650
-		return "", err
648
+		return wxMap, err
651 649
 	}
652 650
 	defer resp.Body.Close()
653 651
 
654
-	return wxMap["openid"], nil
652
+	return wxMap, err
655 653
 }
656 654
 
657 655
 func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code string) (string, error) {
658 656
 	var code2sessionURL = "https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=" + grant_type
659 657
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
658
+	fmt.Println(url)
660 659
 	resp, err := http.DefaultClient.Get(code2sessionURL)
661 660
 	if err != nil {
662 661
 		return "", err
@@ -667,6 +666,6 @@ func SendWxAuthAPIOne(appID string, appSecret string, grant_type string, code st
667 666
 		return "", err
668 667
 	}
669 668
 	defer resp.Body.Close()
670
-
669
+	fmt.Println("2333232232", wxMap)
671 670
 	return wxMap["session_key"], nil
672 671
 }