Foxtable(狐表)用户栏目专家坐堂 → [求助]申通接口写法Base64怎么写?


  共有3361人关注过本帖平板打印复制链接

主题:[求助]申通接口写法Base64怎么写?

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106242 积分:540333 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/12/15 20:37:00 [只看该作者]

全局代码,自己补全命名空间

        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

 回到顶部
总数 22 1 2 3 下一页