XMLWAN před 2 roky
rodič
revize
b6e7994d9c

+ 2 - 1
controllers/xcx_mobile_api_controller.go/xcx_api_controller.go Zobrazit soubor

@@ -1051,7 +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")
1054
+	//code := this.GetString("js_code")
1055
+	var code = "061Vw9Ga18vxSB0KvZIa1dDoGE2Vw9G6"
1055 1056
 
1056 1057
 	openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
1057 1058
 	session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)

+ 4 - 21
service/xcx_mobile_api_service.go Zobrazit soubor

@@ -634,30 +634,13 @@ func GetStoryScoreList(activityID int64, page int64, limit int64) (score []*mode
634 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 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 640
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
659 641
 	fmt.Println("url233232323322323", url)
660 642
 	resp, err := http.DefaultClient.Get(url)
643
+	fmt.Println("resp32332232332322", resp)
661 644
 	if err != nil {
662 645
 		return "", err
663 646
 	}
@@ -672,7 +655,7 @@ func SendWxAuthAPI(appID string, appSecret string, grant_type string, code strin
672 655
 }
673 656
 
674 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 659
 	var url = fmt.Sprintf(code2sessionURL, appID, appSecret, code)
677 660
 	fmt.Println("url233232323322323", url)
678 661
 	resp, err := http.DefaultClient.Get(url)