需求就是模拟登录,然后给手机号码发信息。模拟登录成功了,发消息不成功。完整代码如下
Dim hc1 As New HttpClient("http://xxx.xxx.xxx/operatorlogin")
hc1.FormData.Add("operatorCode", "xxx")
hc1.FormData.Add("password", "xxxx")
hc1.FormData.Add("submit", "xxxxx")
hc1.FormData.Add("userType", "")
Dim ret As String = hc1.getData()
If hc1.rCookies.ContainsKey("error") Then
MessageBox.Show(hc1.rCookies("error"), "提示", MessageBoxButtons.OK ,MessageBoxIcon.Warning)
Else
If hc1.ResponseHeaders("Content-Length")=xxx Then ‘有该返回值说明登录成功
Dim hc As New HttpClient("http://xxx.xxx.xxx.xxx/attemper")
hc.FormData.Add("act", "add")
hc.FormData.Add("actionid", "SMToSendAction")
' hc.FormData.Add("counter", "297")
hc.FormData.Add("counter", "30")
hc.FormData.Add("curPage", "null")
hc.FormData.Add("messageType", "1")
hc.FormData.Add("method", "")
hc.FormData.Add("mobile", "")
hc.FormData.Add("msgContent","123")
hc.FormData.Add("msgContentWap", "")
hc.FormData.Add("myFlag", "prompt")
hc.FormData.Add("needName", "0")
hc.FormData.Add("nextJsp", "")
hc.FormData.Add("now", "now")
hc.FormData.Add("orgAddr", "1065752531750000")
hc.FormData.Add("receiverList", "713xxxxx747")
hc.FormData.Add("receivers", "713xxxxxx747")
hc.FormData.Add("reply", "0")
hc.FormData.Add("report", "0")
hc.FormData.Add("smSendSingle", "true")
hc.FormData.Add("sOnDay", "")
hc.FormData.Add("sSendTime", "1458438655128")
hc.FormData.Add("urlAddress", "")
Dim ret1 As String = hc.getData()
If hc.rCookies.ContainsKey("error") Then
MessageBox.Show(hc.rCookies("error"), "提示", MessageBoxButtons.OK ,MessageBoxIcon.Warning)
Else
OutPut.Show("内容类型:" & hc.ResponseContentType)
OutPut.Show("状态码:" & hc.StatusCode)
MessageBox.Show(ret)
'For Each key As String In hc.ResponseHeaders.Keys '显示服务器返回的头部信息
'OutPut.Show(Key & ":" & hc.ResponseHeaders(key))
'Next
End If
Else
MessageBox.Show("连接错误")
End If
End If
[此贴子已经被作者于2023/9/12 15:50:28编辑过]