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


  共有3319人关注过本帖树形打印复制链接

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

帅哥哟,离线,有人找我吗?
zto001
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
[求助]申通接口写法Base64怎么写?  发帖心情 Post By:2020/12/15 19:01:00 [只看该作者]

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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By:2020/12/15 20:26:00 [只看该作者]

这个东西也要吧
下载地址sdk.rar
这个文件怎么没有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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By: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


 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:105965 积分:538900 威望: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

 回到顶部
帅哥哟,离线,有人找我吗?
zto001
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By:2020/12/15 20:45:00 [只看该作者]

编译错误:模块中的方法不能声明为”Shared".。
错误代码:Public Shared Function LinkTest0 As String


还有那个SDK我怎么引用,他不是dll后缀

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

去掉Shared 字符

那个SDK没有办法用,那是java的,用不了,要找.net的

 回到顶部
帅哥哟,离线,有人找我吗?
zto001
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By:2020/12/15 22:18:00 [只看该作者]

那意思是上面这个.ne转换过来的东西用不了?

 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

sdk用不了和这个.net转换过来的东西有什么关系?

.net的东西foxtable都可以用,有没有用测试咯

 回到顶部
帅哥哟,离线,有人找我吗?
zto001
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1465 积分:10397 威望:0 精华:0 注册:2018/10/16 11:42:00
  发帖心情 Post By:2020/12/15 23:14:00 [只看该作者]

去掉Shared 字符
怎么去掉?删掉这个,还是删掉这段代码(试了都出错)

 回到顶部
帅哥,在线噢!
有点蓝
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

去掉Shared 这个字符。其它.net类型的命名空间都补齐了吗?

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