我试图将数据从VB.NET应用程序发送到php应用程序,我找到了这段代码:
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
但我无法在php上获取发布的数据。它发送标题,但数据号
所以,我需要帮助来找出遗漏的东西。
答案 0 :(得分:0)
我也遇到了同样的问题,仅从评论中得到了解决方案。当您传递二进制数据时,在php中,您需要读取二进制数据作为原始输入
要获取原始帖子数据:
<?php $postdata = file_get_contents("php://input"); ?>