using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Linq;
namespace WebApplication4
{
public partial class _Default : System.Web.UI.Page
{
public string HttpSMSPost(HttpWebRequest hr, string parameters)
{
string strRet = null;
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(parameters);
try
{
hr.KeepAlive = false;
hr.Method = "POST";
hr.ContentType = "application/x-www-form-urlencoded";
hr.ContentLength = data.Length;
Stream newStream = hr.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse myResponse = (HttpWebResponse)hr.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("gb2312"));
strRet = reader.ReadToEnd();
reader.Close();
myResponse.Close();
}
catch (Exception ex)
{
strRet = ex.ToString();
}
return strRet;
}
protected void Page_Load(object sender, EventArgs e)
{
string url = "http://域名/LANZGateway/DirectSendSMSs.asp";
string SMSparameters = "UserID=999999&Account=lanz2016&Password=735FF0028B7831D2783DD7EE98E3095DB94A1D64
&Content=" + System.Web.HttpUtility.UrlEncode("您的注册验证码为8268,该验证码10分钟内有效。如非本人操作请忽略此短信!【浪驰软件】",
Encoding.GetEncoding("GB2312")) + "&Phones=11111111111&ReturnXJ=1";
string targeturl = url.Trim().ToString();
HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
string res = HttpSMSPost(hr, SMSparameters);
Response.Write(res);
}
}
}
/pre> |
XML: <?xml version="1.0" encoding="GB2312"?> <LANZ_ROOT> <ErrorNum>0</ErrorNum> <JobID>2321313130</JobID> <PhonesSend>98</PhonesSend> <ErrPhones>13855556666;13611112222</ErrPhones> <DeductionSMSs>1000</DeductionSMSs> </LANZ_ROOT> JSON: { "LANZ_ROOT": { "ErrorNum": "0", "JobID": "2321313130", "PhonesSend": "98", "ErrPhones": "13855556666;13611112222", "DeductionSMSs": "1000" } }
|