以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]申通接口写法Base64怎么写? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=159152) |
|
-- 作者:zto001 -- 发布时间:2020/12/15 19:01:00 -- [求助]申通接口写法Base64怎么写? Dim hc As new HttpClient("http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do")hc.ContentType = "application/x-www-form-urlencoded charset=UTF-8"hc.FormData.Add("content",报文)hc.FormData.Add("data_digest",报文签名)hc.FormData.Add("api_name",API)hc.FormData.Add("from_appkey",应用key)hc.FormData.Add("from_code",资源code)hc.FormData.Add("to_appkey",注册方appkey)hc.FormData.Add("to_code",注册方资源code)hc.FormData.Add("content",业务)Output.Show(hc.GetData)签名怎么写? MD5会写 APPSign=System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sign , "MD5") Base64怎么写? https://open.sto.cn/#/help/tz5gl0[此贴子已经被作者于2020/12/18 19:13:52编辑过]
|
|
-- 作者:zto001 -- 发布时间:2020/12/15 20:26:00 -- 这个东西也要吧 这个文件怎么没有dll可以调用 2..NET 调用示例: using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; using System.Security.Cryptography; using System.Text; using System.Web; namespace LinkRequest { class Program { public static void Main(string[] args) { string response = LinkTest(); Console.WriteLine(response); Console.ReadLine(); } public static string LinkTest() { byte[] responseArray = null; string url = "http://cloudinter-linkgatewaytest.sto.cn/gateway/link.do"; using (WebClient webClient = new WebClient()) { NameValueCollection postValues = new NameValueCollection(); string secretKey = "123abc"; string c; string dataDigest = 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); } string response = Encoding.UTF8.GetString(responseArray); return response; } //加密 public static string CalculateDigest(string content, string secretKey) { string toSignContent = content + secretKey; System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); byte[] inputBytes = System.Text.Encoding.GetEncoding("utf-8").GetBytes(toSignContent); byte[] hash = md5.ComputeHash(inputBytes); return Convert.ToBase64String(hash); } } }
[此贴子已经被作者于2020/12/15 20:30:38编辑过]
|
|
-- 作者:zto001 -- 发布时间:2020/12/15 20:30:00 -- 转后 Imports System Imports System.Collections.Generic Imports System.Collections.Specialized Imports System.Linq Imports System.Net Imports System.Security.Cryptography Imports System.Text Imports System.Web Namespace LinkRequest Class Program Public Shared Sub Main(ByVal args As String()) Dim response As String = LinkTest() Console.WriteLine(response) Console.ReadLine() End Sub 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 WebClient = New 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 End Class End Namespace |
|
-- 作者:有点蓝 -- 发布时间: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 |
|
-- 作者:zto001 -- 发布时间:2020/12/15 20:45:00 -- 编译错误:模块中的方法不能声明为”Shared".。 错误代码:Public Shared Function LinkTest0 As String 还有那个SDK我怎么引用,他不是dll后缀
|
|
-- 作者:有点蓝 -- 发布时间:2020/12/15 21:07:00 -- 去掉Shared 字符 那个SDK没有办法用,那是java的,用不了,要找.net的
|
|
-- 作者:zto001 -- 发布时间:2020/12/15 22:18:00 -- 那意思是上面这个.ne转换过来的东西用不了? |
|
-- 作者:有点蓝 -- 发布时间:2020/12/15 22:32:00 -- sdk用不了和这个.net转换过来的东西有什么关系? .net的东西foxtable都可以用,有没有用测试咯
|
|
-- 作者:zto001 -- 发布时间:2020/12/15 23:14:00 --
|
|
-- 作者:有点蓝 -- 发布时间:2020/12/16 8:24:00 -- 去掉Shared 这个字符。其它.net类型的命名空间都补齐了吗? |