Public Shared Function LinkTest() As String
Dim responseArray As Byte() = Nothing
Dim url As String = "http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do"
Using webClient As System.Web.WebClient = New System.Web.WebClient()
Dim postValues As NameValueCollection = New NameValueCollection()
Dim secretKey As String = "123abc"
Dim content As String = "{""orderNo"":""8885452262"",""orderSource"":""VIPEO""}"
Dim dataDigest As String = CalculateDigest(content, secretKey)
postValues.Add("content", content)
postValues.Add("data_digest", dataDigest)
postValues.Add("api_name", "OMS_EXPRESS_ORDER_CREATE")
postValues.Add("from_appkey", "sto_test")
postValues.Add("from_code", "sto_test_code")
postValues.Add("to_appkey", "sto_oms")
postValues.Add("to_code", "sto_oms")
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
responseArray = webClient.UploadValues(url, "POST", postValues)
End Using
Dim response As String = Encoding.UTF8.GetString(responseArray)
Return response
End Function
Public Shared Function CalculateDigest(ByVal content As String, ByVal secretKey As String) As String
Dim toSignContent As String = content & secretKey
Dim md5 As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create()
Dim inputBytes As Byte() = System.Text.Encoding.GetEncoding("utf-8").GetBytes(toSignContent)
Dim hash As Byte() = md5.ComputeHash(inputBytes)
Return Convert.ToBase64String(hash)
End Function