以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教钉钉接口调用问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=147109)

--  作者:gudao123456
--  发布时间:2020/3/10 1:20:00
--  请教钉钉接口调用问题
帮助文档了提供了一个调用微信接口的应用程序。我想仿照着做获取钉钉的access_token
钉钉的获取token的访问格式是:\'https://oapi.dingtalk.com/gettoken?corpid=*************=*************
代码如下(只是把帮助文档中的网址改为钉钉的网址,把CopID,和corpsecrtet替换,在钉钉官方开发文档中试过,调用是成功的,不过那里给出的是Java的demo,看不懂。),

Static CreateTime As Date \'记录最近一次生成access_token的时间
Static AccessTocken As String \'记录最近一次生成的access_token
Dim CorpID As String"ww7deed3af842576ed" \'钉钉企业号的CorpID
Dim
Secret As String = "sO7RjwoisX82kB_gcRY4isEU8ZC6sJVcGs6CDlz8Nkc" \'钉钉应用的Secret
Dim tp As TimeSpan = Date.Now - CreateTime
If tp.TotalSeconds > 3600 Then
    Dim url As String = "https://oapi.dingtalk.com/gettoken?corpid={0}&corpsecret={1}"
    Dim hc As New HttpClient(CExp(url, CorpID, Secret))
    Dim ret As String = hc.GetData()
    If ret = "" Then \'如果失败,再尝试一次
        hc.GetData()
    End If
    CreateTime = Date.Now()
    Dim jo As JObject = JObject.Parse(ret)
    If jo("access_token") IsNot Nothing Then
        AccessTocken = jo("access_token")
    Else
        MessageBox.show("获取access_token失败,原因:" & vbcrlf & jo.ToString)
    End If
End If
Return AccessTocken

显示错误代码:40089, 无效的CorpID或corpsecret
不知能否这样直接替换,如果不能,帮助文档中只介绍了微信,怎么呢?谢谢!



--  作者:有点蓝
--  发布时间:2020/3/10 9:04:00
--  
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=145793&replyID=&skin=1

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=136663&replyID=&skin=1

--  作者:gudao123456
--  发布时间:2020/3/10 9:54:00
--  
谢谢!但我在拿分享文档里的实例才命令窗口试运行了一下:
Dim e As RequestEventArgs = Args(0)
Dim wb As New weui
wb.AppendHTML("<script src=\'//g.alicdn.com/dingding/dingtalk-jsapi/2.6.41/dingtalk.open.js\'></script>",True)
wb.AppendHTML("<script src=\'./ding/getCode.js\'></script>")
wb.InsertHTML("","<div id=\'divlist\'>")
wb.InsertHTML("","</div>") \'占位的DIV标签的结束标签 wb.AddPageTitle("","ph1","系统登陆中","钉钉授权中...")
e.WriteString(wb.Build) e.Handled = True

结果显示错误: 未声明:args, 错误代码:Dim e As RequestEventArgs = Args(0)
这个args还需要定义吗?是否是什么空间引用没弄好?谢谢!


--  作者:有点蓝
--  发布时间:2020/3/10 10:11:00
--  
这些是函数代码,不能直接在命令窗口执行的:http://www.foxtable.com/webhelp/topics/0985.gif
--  作者:gudao123456
--  发布时间:2020/3/10 10:17:00
--  
谢谢!