Foxtable(狐表)用户栏目专家坐堂 → [分享]滴滴开发平台对接过程


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

主题:[分享]滴滴开发平台对接过程

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


加好友 发短信
等级:小狐 帖子:387 积分:2930 威望:0 精华:0 注册:2015/4/29 11:50:00
[分享]滴滴开发平台对接过程  发帖心情 Post By:2025/3/8 19:11:00 [只看该作者]

20250308 分享签名算法:
官方文档:https://open.es.xiaojukeji.com/doc/erpapi/oauth/sign.html

Dim localDateTime As DateTime = DateTime.Now ' 本地时间
Dim timestamp As Long = New DateTimeOffset(localDateTime).ToUnixTimeSeconds()
Output.Show( timestamp )
Dim client_id As String = "7df29*********"
Dim sign_key As String = "96*******"
Dim client_secret As String = "00*******"
Dim grant_type As String = "client_credentials"
Dim phone As String = "1*******"

Dim  s As String ="client_id=" & client_id & "&client_secret=" & client_secret & "&grant_type=" & grant_type & "&ph&sign_key=" & sign_key & "&timestamp=" & timestamp 
Output.Show( s)
Dim md5 As New Security.Cryptography.MD5CryptoServiceProvider
Dim bytes As Byte() =  md5.ComputeHash(Encoding.UTF8.GetBytes(s))
Dim result As New StringBuilder(bytes.Length * 2)
For Each b As Byte In bytes
    result.Append(b.ToString("x2")) ' 强制小写格式
Next
Dim sign As String = result.ToString()
Output.Show( sign  )

20250309 分享获取授权 access_token:
官方文档:https://open.es.xiaojukeji.com/doc/erpapi/oauth/auth.html

Dim ur As String = "https://api.es.xiaojukeji.com/river/Auth/authorize"
Dim hc As new HttpClient(Cexp(ur))
hc.Headers.Add("content-type","application/json")
hc.Headers.Add("application","x-www-form-urlencoded") 
hc.FormData.Add("client_id",client_id)
hc.FormData.Add("client_secret",client_secret)
hc.FormData.Add("grant_type",grant_type)
hc.FormData.Add("phone",phone )
hc.FormData.Add("timestamp",timestamp )
hc.FormData.Add("sign",sign )
Dim jo As New JObject
Output.Show(jo.ToString)
jo = JObject.Parse(hc.GetData)
Output.Show(jo.ToString)
返回数据
{
  "access_token": "********",
  "expires_in": 1800,
  "token_type": "Bearer",
  "scope": "******"
}




[此贴子已经被作者于2025/3/9 8:54:50编辑过]

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


加好友 发短信
等级:小狐 帖子:387 积分:2930 威望:0 精华:0 注册:2015/4/29 11:50:00
  发帖心情 Post By:2025/3/9 12:39:00 [只看该作者]

接口调通,可正常使用。
'新增部门
官方文档:https://open.es.xiaojukeji.com/doc/erpapi/budgetCenter/add.html

Dim ur As String = "https://api.es.xiaojukeji.com/river/BudgetCenter/add"
Dim hc As new HttpClient(Cexp(ur))
hc.Headers.Add("content-type","application/json")

hc.FormData.Add("client_id",client_id)
hc.FormData.Add("access_token",access_token)
hc.FormData.Add("timestamp",timestamp )
hc.FormData.Add("company_id",company_id)
hc.FormData.Add("name","test1")
hc.FormData.Add("type",1)
hc.FormData.Add("budget_cycle",1)
hc.FormData.Add("total_quota",0)
hc.FormData.Add("sign_key",sign_key)
hc.FormData.Add("sign",sign)
''
Dim jo As New JObject
jo = JObject.Parse(hc.GetData)
Output.Show(jo.ToString)

返回数据
{
  "errno": 0,
  "errmsg": "SUCCESS",
  "data": {
    "id": "112******"
  },
  "request_id": "mbS****"
}


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


加好友 发短信
等级:超级版主 帖子:112699 积分:573834 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2025/3/9 20:01:00 [只看该作者]

多谢分享

 回到顶部