我在VB中遇到过这个函数,有人可以帮助我在PHP中转换它。 我如何将像API KEY这样的特定值解析为http标头?比如说API_KEY变量。
非常感谢...
Dim request = TryCast(System.Net.WebRequest.Create("https://domain.com/getticker"),
System.Net.HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Using writer = New System.IO.StreamWriter(request.GetRequestStream())
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes("timestamp=1387132060")
request.ContentLength = byteArray.Length
writer.Write(byteArray)
writer.Close()
End Using
Dim responseContent As String
Using response = TryCast(request.GetResponse(), System.Net.HttpWebResponse)
Using reader = New System.IO.StreamReader(response.GetResponseStream())
responseContent = reader.ReadToEnd()
End Using
End Using