2 my6731083 my6731083 于 2015.07.23 17:43 提问

求大神把这段代码完成的功能用asp代码写出来

protected void Button1_Click(object sender, System.EventArgs e)
{
XmlDocument doc = new XmlDocument();
String Account = TextBox1.Text.ToString();
String Password = TextBox2.Text.ToString();
String url = "http://3tong.net/http/sms/Submit";
String Phone = TextBox3.Text.ToString();
String sendtime = TextBox4.Text.ToString();
String sign = TextBox5.Text.ToString();
String subcode = TextBox6.Text.ToString();
String Content = TextBox8.Text.ToString();
String msgid = TextBox7.Text.ToString();
String message = DocXml(Account,Password,msgid,Phone,Content,subcode,sendtime,sign);

    WebClient webClient = new WebClient();
    NameValueCollection postValues = new NameValueCollection();
    postValues.Add("message", message);


    //向服务器发送POST数据
    byte[] responseArray = webClient.UploadValues(url, postValues);
    TextBox9.Text = Encoding.UTF8.GetString(responseArray);
}

3个回答

my6731083
my6731083   2015.07.23 18:16

private static string DocXml(string account, string password, string msgid, string phones, string content,string subcode,string sendtime,string sign)
{
XmlDocument doc = new XmlDocument();
XmlNode xmlnode = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.AppendChild(xmlnode);
XmlElement xe1 = doc.CreateElement("response");
XmlElement sub1 = doc.CreateElement("account");
sub1.InnerText = account;
xe1.AppendChild(sub1);
XmlElement sub2 = doc.CreateElement("password");
sub2.InnerText = md5(password);
xe1.AppendChild(sub2);
XmlElement sub3 = doc.CreateElement("msgid");
sub3.InnerText = msgid;
xe1.AppendChild(sub3);
XmlElement sub4 = doc.CreateElement("phones");
sub4.InnerText = phones;
xe1.AppendChild(sub4);
XmlElement sub5 = doc.CreateElement("content");
sub5.InnerText = content;
xe1.AppendChild(sub5);
XmlElement sub6 = doc.CreateElement("subcode");
sub6.InnerText = subcode;
xe1.AppendChild(sub6);
XmlElement sub7 = doc.CreateElement("sendtime");
sub7.InnerText = sendtime;
xe1.AppendChild(sub7);
XmlElement sub8 = doc.CreateElement("sign");
sub8.InnerText = sign;
xe1.AppendChild(sub8);
doc.AppendChild(xe1);
return xe1.OuterXml;
}

cuiwei1026522829
cuiwei1026522829   Ds   Rxr 2015.07.24 00:11

应该是让你仿照上面这段写。。

CSDNXIAOD
CSDNXIAOD   2015.07.24 09:37

只是觉得这段代码好
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

Csdn user default icon
上传中...
上传图片
插入图片