以下是C#转.net后的代码
Class SurroundingClass
Private Const host As String = "https://ali-deliver.showapi.com"
Private Const path As String = "/showapi_expInfo"
Private Const method As String = "GET"
Private Const appcode As String = "你自己的AppCode"
Private Shared Sub Main(ByVal args As String())
Dim querys As String = "com=zhongtong&nu=535962308717&receiverPhone=receiverPhone&senderPhone=senderPhone"
Dim bodys As String = ""
Dim url As String = host + path
Dim httpRequest As HttpWebRequest = Nothing
Dim httpResponse As HttpWebResponse = Nothing
If 0 < querys.Length Then
url = url & "?" + querys
End If
If host.Contains("https://") Then
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf CheckValidationResult)
httpRequest = CType(WebRequest.CreateDefault(New Uri(url)), HttpWebRequest)
Else
httpRequest = CType(WebRequest.Create(url), HttpWebRequest)
End If
httpRequest.Method = method
httpRequest.Headers.Add("Authorization", "APPCODE " & appcode)
If 0 < bodys.Length Then
Dim data As Byte() = Encoding.UTF8.GetBytes(bodys)
Using stream As Stream = httpRequest.GetRequestStream()
stream.Write(data, 0, data.Length)
End Using
End If
Try
httpResponse = CType(httpRequest.GetResponse(), HttpWebResponse)
Catch ex As WebException
httpResponse = CType(ex.Response, HttpWebResponse)
End Try
Console.WriteLine(httpResponse.StatusCode)
Console.WriteLine(httpResponse.Method)
Console.WriteLine(httpResponse.Headers)
Dim st As Stream = httpResponse.GetResponseStream()
Dim reader As StreamReader = New StreamReader(st, Encoding.GetEncoding("utf-8"))
Console.WriteLine(reader.ReadToEnd())
Console.WriteLine(vbLf)
End Sub
Public Shared Function CheckValidationResult(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal errors As SslPolicyErrors) As Boolean
Return True
End Function
End Class