Dim hangshu As Integer= Tables("在建项目").Rows.Count-1 '判断行数是否为空
If hangshu < 0 Then
Return
End If
If hangshu = Tables("在建项目").GrandTotal Then
Return
End If
红色代码无效 帮忙改一下
With Tables("在建项目")
If .TopPosition = -1 Then '汇总行不执行
Return
End If
End With
'--------------企业号GetQYAccessToken---------------------------
Static yyyCreateTime As Date '记录最近一次生成access_token的时间
Static yyyAccessTocken As String '记录最近一次生成的access_token
Dim CorpID As String = Tables("S_基础数据").rows(23)("内容") '企业号的CorpID
Dim Secret As String = Tables("S_基础数据").rows(27)("内容") '管理组的Secret27
Dim tp As TimeSpan = Date.Now - yyyCreateTime
If tp.TotalSeconds > 3600 Then
Dim url As String = "https://qyapi.weixin.qq.com/cgi-bin/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
yyyCreateTime = Date.Now()
Dim jo As JObject = JObject.Parse(ret)
If jo("access_token") IsNot Nothing Then
yyyAccessTocken = jo("access_token")
MessageBox.show(yyyAccessTocken)
Else
MessageBox.show("获取access_token失败,原因:" & vbcrlf & jo.ToString)
End If
End If
Return yyyAccessTocken
上面代码能正常获取yyyAccessTocken
Dim st As New Date(1970,1,1,8,0,0)
Dim t1 As Integer = CInt((Date.Today.AddDays(-100) - st).TotalSeconds()) '时间戳开始时间
Dim t2 As Integer = CInt((Date.Now - st).TotalSeconds()) '时间戳结束时间
Dim ur As String = "https://qyapi.weixin.qq.com/cgi-bin/corp/getapprovaldata?access_token={0}"
Dim hc As New HttpClient(Cexp(ur, Functions.Execute("GetQYAccessToken4"))) '企业号应用
Dim jo As New JObject
jo("starttime") = t1
jo("endtime") = t2
hc.Content = jo.Tostring()
jo = JObject.Parse(hc.GetData)
Dim json As String = jo("data").ToString()
MessageBox.Show(json)
为啥这里是空值
[此贴子已经被作者于2024/4/4 11:00:16编辑过]
……
jo("endtime") = t2
hc.Content = jo.Tostring()
dim s as stirng = hc.GetData)
MessageBox.Show(s) ‘这样弹出什么内容?’
48002
此主题相关图片如下:搜狗高速浏览器截图20240407080657.png
难道是权限问题
没有权限调用这个接口。可能CorpID, Secret对应的应用没有权限