这是很久以前写的,可以执行成功,请问这段代码现在可以简化吗?
Dim str_name As String="名字"
Dim str_sign As String="中心"
'Dim str_SearchTable As String=args(2)
Dim str_tel As String="13312345678"
Dim str_content As String="计算机测试"
'Dim str_ReplyMessage As String=args(4) '用于判断是否需要接收发送成功的 弹出提醒
'Dim str_DeptName As String =args(5) '传递部门过来
str_content=str_sign & "提示您:" & str_content
''''''''''''''''''''''''''''
Dim user As String = "yyy"
Dim salt As String = "123"
Dim str_temp As String = "password" & salt
Dim auth = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str_temp,"MD5").ToUpper
Dim msg As String = "user=" & user & "&salt=" & salt & "&auth=" & auth '输入请求传参数
'msgbox(msg)
''''''''''''''以下为POST方法 为了登陆
Dim req As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://10.10.10.10:9527/session")
req.Method = "POST"
req.timeout = 5000
req.C
req.ContentLength = msg.Length
Dim cookieCon As new System.Net.CookieContainer() '声明cookiescon
req.CookieContainer = cookieCon '给req的container赋值
Dim postBytes() As Byte = Encoding.UTF8.GetBytes(msg)
Dim requestStream As Object = req.GetRequestStream()
requestStream.Write(postBytes, 0, postBytes.Length)
requestStream.Close()
Dim pos As System.Net.WebResponse = req.GetResponse()
Dim cookieheader As String = req.CookieContainer.GetCookieHeader(new Uri("http://10.10.10.10:9527/"))
Dim mycookie = req.CookieContainer
'msgbox(cookieheader ) '显示cookie
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm,encoding.utf8)
Dim str As String = reader.ReadToEnd
stm.Dispose()
'msgbox(str) '查收errorcode 的值
''''''''''''''以下为POST方法 为了发短信
Dim desttermid As String = str_tel
Dim content As String = str_content
Dim mode As String = "2"
Dim msg3 As String = "desttermid=" & desttermid & "&c&mode=" & mode '输入请求传参数
'msgbox(msg3)
'以下为POST方法 '为了发短信
Dim req3 As System.Net.HttpWebRequest = System.Net.WebRequest.Create("http://10.10.10.10:9527/message")
req3.Method = "POST"
req3.timeout = 5000
req3.C
'req3.ContentLength = msg3.Length
'Dim cookieCon As new System.Net.CookieContainer() '声明cookiescon
req3.CookieContainer = mycookie '给req的container赋值
'dim postBytes() As Byte = Encoding.UTF8.GetBytes(msg3)
Dim postBytes3() As Byte= Encoding.UTF8.GetBytes(msg3)
Dim requestStream3 As Object = req3.GetRequestStream()
'msgbox(1)
requestStream3.Write(postBytes3, 0, postBytes3.Length)
'msgbox(2)
requestStream3.Close()
Dim pos3 As System.Net.WebResponse = req3.GetResponse()
Dim cookieheader3 As String = req3.CookieContainer.GetCookieHeader(new Uri("http://10.10.10.10:9527/"))
mycookie = req3.CookieContainer
'msgbox(cookieheader3)
Dim stm3 As System.IO.Stream = pos3.GetResponseStream()
Dim reader3 As New System.IO.StreamReader(stm3,encoding.utf8)
Dim str3 As String = reader3.ReadToEnd
stm3.Dispose()
'msgbox(str3)
'''''''''''''''''''''''''''''''''''''''
'以下为DELETE方法
Dim req2 = System.Net.WebRequest.Create("http://10.10.10.10:9527/session")
req2.Method = "DELETE"
req2.timeout = 5000
req2.C
req2.CookieContainer = mycookie
Dim pos2 As System.Net.WebResponse = req2.GetResponse()
Dim stm2 As System.IO.Stream = pos2.GetResponseStream()
Dim reader2 As New System.IO.StreamReader(stm2,encoding.utf8)
Dim str2 As String = reader2.ReadToEnd
stm2.Dispose()
'msgbox(str2) 这是delete方法的回执