public async Task <JsonResult> Code2Session()
        {
            using (var client = new WxApi.WxApiClient())
            {
                var request = new WxApiCode2SessionRequest()
                {
                    AppId  = "wx346f2583af4c5a8f",
                    Code   = "",
                    Secret = ""
                };
                var s = await client.ExecuteAsync(request);

                return(Json(new { Code = 1, Msg = "成功" }));
            }
        }
Exemplo n.º 2
0
        public async Task <JsonResult> Code2Session(string AppId, string Secret, string Code)
        {
            using (var client = new WxApi.WxApiClient())
            {
                var sw = new Stopwatch();
                sw.Start();
                var request = new WxApiCode2SessionRequest()
                {
                    AppId  = AppId,  // "wx13c069c9a4a9aa48",
                    Code   = Code,   //"001hTd1001lt8L1kPW000FX4wG1hTd1W",
                    Secret = Secret, // "73cc6fe4cb0dbc22f432e297e4e685da" //oknLJ1aXS1vhkw_wg6UrKXFEGFRg
                };
                var s = await client.ExecuteAsync(request);

                logging.LogInformation(s.ErrCode + "msg: " + s.Errmsg + " " + s.OpenId);
                var time = sw.ElapsedMilliseconds;
                sw.Stop();
                return(Json(new { Code = 1, Msg = "成功", Data = s.OpenId }));
            }
        }