Foxtable(狐表)用户栏目专家坐堂 → [求助]这个api怎么写?空包api


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

主题:[求助]这个api怎么写?空包api

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


加好友 发短信
等级:超级版主 帖子:111427 积分:567211 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/7 13:54:00 [显示全部帖子]

全局代码
public Function generateSign(ByVal dict As Dictionary(Of String, String)) As String
        Dim str As String = ""

        For Each key As String In dict.Keys
            str = str & key & dict(key)
        Next

        Dim md5psw As String = MD5Encrypt2(appSecret, 16).ToLower()
        str = md5psw & str & md5psw
        Return MD5Encrypt2(str, 32).ToUpper()
    End Function

    public Function MD5Encrypt2(ByVal password As String, ByVal bit As Integer) As String
        Dim md5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider()
        Dim hashedDataBytes As Byte()
        hashedDataBytes = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(password))
        Dim tmp As StringBuilder = New StringBuilder()

        For Each i As Byte In hashedDataBytes
            tmp.Append(i.ToString("x2"))
        Next

        If bit = 16 Then
            Return tmp.ToString().Substring(8, 16)
        ElseIf bit = 32 Then
            Return tmp.ToString()
        Else
            Return String.Empty
        End If
    End Function

调用
Dim postedJObject As JObject = New JObject()
postedJObject.Add("Platform", "拼多多申通")
postedJObject.Add("SendContact", "sir张")
postedJObject.Add("SendOfficePhone", "18225405356")
postedJObject.Add("UserId", "8989")
postedJObject.Add("SendCellPhone", "18225405356")
postedJObject.Add("SendState", "浙江省")
postedJObject.Add("SendCity", "金华市")
postedJObject.Add("SendDistrict", "义乌市")
postedJObject.Add("SendAddress", "柳青(五区)66栋")
postedJObject.Add("ProductTitle", "衣服")
postedJObject.Add("Weight", "2")
Dim jArray As JArray = New JArray()
Dim rOrder As JObject = New JObject()
rOrder.Add("OrderNo", "3112e2e2e111e")
rOrder.Add("Contact", "唐淑莲")
rOrder.Add("OfficePhone", "15672618101")
rOrder.Add("CellPhone", "15672618101")
rOrder.Add("State", "湖北省")
rOrder.Add("City", "黄冈市")
rOrder.Add("District", "英山县")
rOrder.Add("Address", "温泉镇西汤河民政局斜对面一修家电服务中心")
jArray.Add(rOrder)
Dim rOrder1 As JObject = New JObject()
rOrder1.Add("OrderNo", "3112e2e2e111e22")
rOrder1.Add("Contact", "唐淑莲")
rOrder1.Add("OfficePhone", "15672618101")
rOrder1.Add("CellPhone", "15672618101")
rOrder1.Add("State", "湖北省")
rOrder1.Add("City", "黄冈市")
rOrder1.Add("District", "英山县")
rOrder1.Add("Address", "温泉镇西汤河民政局斜对面一修家电服务中心")
jArray.Add(rOrder1)
postedJObject.Add("Raddress", jArray)

Dim 订单详情 As String = CompressJson(postedJObject)

Dim hc As new HttpClient("http://kongbao100.cn/OrderSubmit/index.asp")
hc.C
hc.FormData.Add("appKey","zto001")
hc.FormData.Add("logiType","buykongbao")
hc.FormData.Add("orders",订单详情 )
hc.FormData.Add("timestamp",Date.Now.ToString("yyyy-MM-dd HH:mm:ss"))

Dim dict As new Dictionary(of String, String)
dict.Add("appKey", "zto001")
dict.Add("logiType", "buykongbao")
dict.Add("orders", 订单详情)
dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
Dim 签名 As String = generateSign(dict)
hc.FormData.Add("sign",签名 )
dim ret = hc.GetData
msgbox(ret)

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:c# demo.zip



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


加好友 发短信
等级:超级版主 帖子:111427 积分:567211 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/9 9:58:00 [显示全部帖子]

我是直接从官方示例转换过来的。有能力的自己优化当然就更好

 回到顶部