cookies应该没有问题吧,下面这段代码,发短信和查收回复 都是用的str_cookies ,如果有问题,为什么登陆后的发短信是成功的呢?
Dim str_name As String="王昆"
Dim str_sign As String="信息科"
'Dim str_SearchTable As String=args(2)
Dim str_tel As String="15327667745"
Dim str_content As String="上行短信第3遍"
Dim str_status As Boolean=True '用于判断是否需要接收发送成功的 弹出提醒
str_content=str_sign & "提示您:" & str_content
Dim str_cookies As String
Dim user As String = "yc_yyy_xmgl"
Dim salt As String = "123"
Dim str_temp As String = "cqq7@XfW1K4WA7&p0Y&tg4&4" & salt
Dim auth = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str_temp,"MD5").ToUpper '字符串md5化
Dim hc As New HttpClient("http://10.27.254.6:9527/session") '登陆
hc.FormData.Add("user",user)
hc.FormData.Add("salt",salt)
hc.FormData.Add("auth",auth)
Dim ret As String = hc.getData()
Dim jo As JObject= JObject.Parse(ret)
For Each key As String In hc.rCookies.Keys
'msgbox(key) 'TWISTED_SESSION
'msgbox(hc.rCookies(key)) '3f9eeb6d92868f039034f24483a2c52f
str_cookies= hc.rCookies(key)
Next
'msgbox(4)
'在提交的时候附带cookies
Dim hc_send As New HttpClient("http://10.27.254.6:9527/message") '发短信
hc_send.sCookies.Add("TWISTED_SESSION",str_cookies)
hc_send.FormData.Add("desttermid",str_tel)
hc_send.FormData.Add("content",str_content)
hc_send.FormData.Add("mode","2") '表示需要查收回复
Dim ret_send As String = hc_send.getData()
Dim jo_send As JObject= JObject.Parse(ret_send)
msgbox(jo_send("errorcode").ToString)
msgbox(jo_send("taskid").ToString)
'接收回复
'Dim str_reply As String ="http://sms.yc.hb.cegn.cn:9527/message/taskid/" &
'Dim hc_send As New HttpClient("http://10.27.254.6:9527/message") '发短信
'hc_send.sCookies.Add("TWISTED_SESSION",str_cookies)
'hc_send.FormData.Add("desttermid",str_tel)
'hc_send.FormData.Add("content",str_content)
'hc_send.FormData.Add("mode","2")
'msgbox(5)
' 接收发送后的返回信息
Dim dr_receipt As Row = Tables("短信通知回执表").AddNew
dr_receipt("returnstatus") = jo_send("errorcode")
If str_status=True Then '如果需要弹出提醒则弹,否则不弹
If jo_send("errorcode") ="0" Then '如果返回发送成功信息
MessageBox.Show("发送成功")
Else
MessageBox.Show("发送失败")
End If
End If
dr_receipt("taskID") = jo_send("taskID")
dr_receipt("回执时间") = Date.Now
dr_receipt("发送号码") = str_tel
dr_receipt("发送内容") = str_content
dr_receipt("姓名")= str_name '保存发送对象的姓名在通知回执里
dr_receipt.Save ' 保存回执
'Functions.Execute("智慧宜昌短信平台",dr("任务_责任人"),"计算机中心","人员联系方式字典",str_content,True ))
Dim str_name As String="王"
Dim str_sign As String="信科"
'Dim str_SearchTable As String=args(2)
Dim str_tel As String="15311111111"
Dim str_content As String="上行短信第3遍"
Dim str_status As Boolean=True '用于判断是否需要接收发送成功的 弹出提醒
str_content=str_sign & "提示您:" & str_content
Dim str_cookies As String
Dim user As String = "yc_yy"
Dim salt As String = "123"
Dim str_temp As String = "cqq7@" & salt
Dim auth = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str_temp,"MD5").ToUpper '字符串md5化
Dim hc As New HttpClient("http://10.10.10.10:10/session") '登陆
hc.FormData.Add("user",user)
hc.FormData.Add("salt",salt)
hc.FormData.Add("auth",auth)
Dim ret As String = hc.getData()
Dim jo As JObject= JObject.Parse(ret)
For Each key As String In hc.rCookies.Keys
'msgbox(key) 'TWISTED_SESSION
'msgbox(hc.rCookies(key)) '3f9eeb6d92868f039034f24483a2c52f
str_cookies= hc.rCookies(key)
Next
'msgbox(4)
'在提交的时候附带cookies
Dim hc_send As New HttpClient("http://10.10.10.10:10/message") '发短信
hc_send.sCookies.Add("TWISTED_SESSION",str_cookies)
hc_send.FormData.Add("desttermid",str_tel)
hc_send.FormData.Add("content",str_content)
hc_send.FormData.Add("mode","2") '表示需要查收回复
Dim ret_send As String = hc_send.getData()
Dim jo_send As JObject= JObject.Parse(ret_send)
msgbox(jo_send("errorcode").ToString)
msgbox(jo_send("taskid").ToString)
' 接收发送后的返回信息
Dim dr_receipt As Row = Tables("短信通知回执表").AddNew
dr_receipt("returnstatus") = jo_send("errorcode")
If str_status=True Then '如果需要弹出提醒则弹,否则不弹
If jo_send("errorcode") ="0" Then '如果返回发送成功信息
MessageBox.Show("发送成功")
Else
MessageBox.Show("发送失败")
End If
End If
dr_receipt("taskID") = jo_send("taskID")
dr_receipt("回执时间") = Date.Now
dr_receipt("发送号码") = str_tel
dr_receipt("发送内容") = str_content
dr_receipt("姓名")= str_name '保存发送对象的姓名在通知回执里
dr_receipt.Save ' 保存回执
'查收回复
Dim req = System.Net.WebRequest.Create("http://10.10.10.10:10/message/taskid/" & "41d6d7336c6eaca81a62d2100e4c7")
req.Method = "GET"
Dim cookieCon = new System.Net.CookieContainer
req.CookieContainer = cookieCon
msgbox(str_cookies)
Dim ck As new System.Net.Cookie("TWIST_SESSION", str_cookies)
req.CookieContainer.add(new Uri("http://10.10.10.10"), ck)
Dim pos = req.GetResponse()
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()