IA.Common/MessageHelper.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Configuration;
using System.IO;
using System.Net;
using System.Text;
namespace IA.Common
{
public class MessageHelper
{
private static readonly string smsAccount = ConfigurationManager.AppSettings["SMSAccount"]; //用户名
private static readonly string smsPwd = ConfigurationManager.AppSettings["SMSPwd"]; //密码MD5
public static bool SendSms(string cellphone, string content)
{
try
{
string md5Password = TextHelper.GetMd5(smsPwd);
string tempStr = string.Format("uid={0}&pwd={1}&mobile={2}&content={3}", smsAccount, md5Password, cellphone, content);
byte[] bTemp = Encoding.GetEncoding("GBK").GetBytes(tempStr);
string postReturn = doPostRequest("http://http.yunsms.cn/tx/", bTemp);
return postReturn == "100";
}
catch (Exception ex)
{
LogHelper.Error(ex.Message);
throw;
}
}
private static string doPostRequest(string url, byte[] bData)
{
string strResult;
var hwRequest = (HttpWebRequest)WebRequest.Create(url);
try
{
hwRequest.Timeout = 5000;
hwRequest.Method = "POST";
hwRequest.ContentType = "application/x-www-form-urlencoded";
hwRequest.ContentLength = bData.Length;
using (var smWrite = hwRequest.GetRequestStream())
{
smWrite.Write(bData, 0, bData.Length);
smWrite.Close();
}
}
catch (Exception ex)
{
LogHelper.Error(ex.Message);
throw;
}
try
{
using (var hwResponse = (HttpWebResponse)hwRequest.GetResponse())
using (StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.ASCII))
{
后面还有 15 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
