/// <summary> /// 发送短信验证码 /// </summary> /// <param name="phone">手机号码</param> /// <param name="phoneCode">验证码</param> /// <returns></returns> public async Task HttpPostPhoneCodeAsync(string clientIp, string phone, string phoneCode) { await Task.Run(() => { try { var paramsList = new Dictionary <string, string>(); paramsList.Add("mob", phone); paramsList.Add("msg", string.Format(ConfigHelp.ConfigObject["phoneCodeMessage"].ToString(), phoneCode)); paramsList.Add("pswd", ConfigHelp.ConfigObject["messagePostPswd"].ToString()); var headList = new Dictionary <string, string>(); headList.Add("clientIPAddr", clientIp); headList.Add("requestAccount", ConfigHelp.ConfigObject["messagePostAccount"].ToString()); HttpHelper.GetResponseString(HttpHelper.CreatePostHttpResponse( ConfigHelp.ConfigObject["messagePostUrlPath"].ToString(), paramsList, headList, 300, string.Empty, null)); HttpSendLog.InfoLogAsync( "HttpSendCode HttpPostPhoneCodeAsync run success! clientIp:{0} phone:{1} phoneCode:{2} ", clientIp, phone, phoneCode); } catch (Exception e) { HttpSendLog.ErrorLogAsync( "HttpSendCode HttpPostPhoneCodeAsync run success! clientIp:{0} phone:{1} phoneCode:{2} err:{3}", clientIp, phone, phoneCode, e); } }); }
public static string HttpPostData(string url, IDictionary <string, string> parameters, Encoding requestEncoding) { HttpWebResponse response = HttpHelper.CreatePostHttpResponse(url, parameters, null, null, requestEncoding, null); Stream stream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(stream); return(streamReader.ReadToEnd()); }
/// <summary> /// 发送日志 /// create by gloomy 2017-12-25 15:46:08 /// </summary> /// <param name="logState">日志状态(INFO,ERROR,DEBUG)</param> /// <param name="logContent"></param> /// <returns></returns> private static void SendLog(string logState, string logContent) { if (!Convert.ToBoolean(ConfigHelp.ConfigObject["isWriteLog"].ToString())) {//不打印日志 Console.WriteLine("{0}: {1}", logState, logContent); return; } var dicArray = new Dictionary <string, string>(); dicArray.Add("logState", logState); dicArray.Add("logContent", logContent); HttpHelper.GetResponseString(HttpHelper.CreatePostHttpResponse( string.Format("http://127.0.0.1:{0}{1}/unitWriteLog", ConfigHelp.ConfigObject["serverListeningPort"], ConfigHelp.ConfigObject["rootPrefix"]) , dicArray, new Dictionary <string, string>(), 3000, string.Empty, null)); }