dongzhao3040 2016-09-15 12:50
浏览 142

使用vb.net将json数据发布到php

I'm trying to send data from a VB.NET Application to a php application, i found this code:

Private Function SendRequest(uri As Uri, jsonDataBytes As Byte(),contentType As String, method As String) As String
    Dim req As WebRequest = WebRequest.Create(uri)
    req.ContentType = contentType
    req.Method = method
    req.ContentLength = jsonDataBytes.Length


    Dim stream = req.GetRequestStream()
    stream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
    stream.Close()

    Dim response = req.GetResponse().GetResponseStream()

    Dim reader As New StreamReader(response)
    Dim res = reader.ReadToEnd()
    reader.Close()
    response.Close()

    Return res
End Function

Dim data = Encoding.UTF8.GetBytes(jsonSring)
Dim result_post = SendRequest(uri, data, "application/json", "POST")

at: source

But I can't get the posted data on php. It sends the headers, but the data no.

So, I need help to figure it out what is missing.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 chaquopy python 安卓
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 有没有帮写代码做实验仿真的
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥30 vmware exsi重置后登不上
    • ¥15 易盾点选的cb参数怎么解啊
    • ¥15 MATLAB运行显示错误,如何解决?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题