/// <summary>
        /// HttpGetRequest 返回结果为一个对象
        /// </summary>
        /// <param name="interfaceUrl"></param>
        /// <param name="postValue"></param>
        /// <returns></returns>
        public static T HttpGetRequest <T>(string interfaceUrl)
        {
            string sss = HttpGetRequestAsString(interfaceUrl);

            LogOpert.AddWeiXinMessage("获取wxAccesstoken结果21:" + sss);
            return(JsonHelper.ParseFormJson <T>(sss));
        }
Exemple #2
0
        /// <summary>
        /// 通过appID和appsecret获取Access_token
        /// </summary>
        /// <returns></returns>
        private static MAccessToken GetAccesstokenFromWX()
        {
            try
            {
                //// 微信API地址
                string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

                //// 微信平台的APPID
                string appid = WebConfigeOpert.GetWXappid();

                //// 微信平台的密码
                string secret = WebConfigeOpert.GetWXAppSecret();

                string       strUrl = wxAPIURL + "cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret;
                MAccessToken mode   = PublicTools.HttpGetRequest <MAccessToken>(strUrl);
                LogOpert.AddWeiXinMessage("获取wxAccesstoken结果:" + mode.access_token);
                return(mode);
            }
            catch (Exception ex)
            {
                LogOpert.AddWeiXinMessage("获取wxAccesstoken异常:" + ex);
            }

            return(null);
        }