Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Net.Http
Imports System.Security.Cryptography
Imports System.Text
Imports System.Threading.Tasks
Namespace ConsoleApp1
Class Program
Private Shared Async Function Main(ByVal args As String()) As Task
Dim appKey = "d577e7b5024ad20446e10"
Dim appSec = "0e8e9457d493666ee2f5adb783e69abb"
Dim js"type"":0,""orderCode"":""210107000003719103"",""billCode"":""""}"
Using client As HttpClient = New HttpClient()
Using content = New StringContent(jsonStr, Encoding.UTF8, "application/json")
content.Headers.Add("x-appKey", appKey)
Dim digest = GetSign(jsonStr, appKey, appSec)
content.Headers.Add("x-datadigest", digest)
Dim response As HttpResponseMessage = Await client.PostAsync("https://japi-test.zto.com/zto.open.getOrderInfo", content)
response.EnsureSuccessStatusCode()
Dim responseBody As String = Await response.Content.ReadAsStringAsync()
Console.WriteLine(responseBody)
End Using
End Using
Console.ReadLine()
End Function
Public Shared Function GetSign(ByVal content As String, ByVal appKey As String, ByVal appSec As String) As String
Dim fullContent As String = content & appSec
Dim buytes As Byte() = Encoding.GetEncoding("UTF-8").GetBytes(fullContent)
Using md5 As MD5 = New MD5CryptoServiceProvider()
Dim outBytes = md5.ComputeHash(buytes)
Return Convert.ToBase64String(outBytes)
End Using
End Function
End Class
End Namespace