Foxtable(狐表)用户栏目专家坐堂 → [求助]怎么把json数据post出去


  共有1922人关注过本帖树形打印复制链接

主题:[求助]怎么把json数据post出去

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/16 12:50:00 [显示全部帖子]

Dim name As String="张三"
Dim id As String="abc"
Dim time As String =DateDiff("s", new Date(1970, 1, 1), Now())
Dim msg As String = "username=" & name &"&idcard=" & id & "&_=" & time
msgbox(msg)
Dim req = System.Net.WebRequest.Create("https://zscx.zjsafety.gov.cn/examweb/api/v2/certificate/query_json.xhtml")
req.Method = "POST"
req.Timeout = 5000
req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"
req.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:66.0) Gecko/20100101 Firefox/66.0"
Dim aryBuf As Byte() = Encoding.GetEncoding("utf-8").GetBytes(msg)
req.ContentLength = aryBuf.Length
Dim writer = req.GetRequestStream()
writer.Write(aryBuf, 0, aryBuf.Length)
writer.Close()
writer.Dispose()
Dim pos = req.GetResponse
Dim stm As System.IO.Stream = pos.GetResponseStream()
Dim reader As New System.IO.StreamReader(stm)
Dim str As String = reader.ReadToEnd
pos.Close
stm.Close
reader.close

msgbox(str)


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/16 12:54:00 [显示全部帖子]

Dim name As String="张三"
Dim id As String="abc"
Dim hc As New HttpClient("https://zscx.zjsafety.gov.cn/examweb/api/v2/certificate/query_json.xhtml")
hc.contentType = "application/x-www-form-urlencoded; charset=UTF-8"
hc.Timeout = 5 '设置超时为5秒
Dim time As String =DateDiff("s", new Date(1970, 1, 1), Now())
Dim msg As String = "username=" & name &"&idcard=" & id & "&_=" & time
hc.Content = msg
Dim ret As String = hc.GetData()
MessageBox.Show(ret)
[此贴子已经被作者于2019/5/16 12:54:10编辑过]

 回到顶部