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
请上上面红色字体的 狐表代码 应该怎么写呢?
[此贴子已经被作者于2024/6/30 21:56:23编辑过]
补上命名空间
Net.ServicePointManager.ServerCertificateValidationCallback = New Net.Security.RemoteCertificateValidationCallback(AddressOf CheckValidationResult)httpRequest = CType(Net.WebRequest.CreateDefault(New Uri(url)), Net.HttpWebRequest)
[此贴子已经被作者于2024/6/30 22:30:21编辑过]
以下是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
错误!所有.net的类型都需要命名空间,Foxtable只是使用了.net部分功能,所以并没有把所有.net的dll以及对应的命名空间都引用到Foxtable里,因此需要用到Foxtable没有的功能的时候基本都需要添加对应的命名空间