以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 企业微信获取人员信息 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145750) |
|||
-- 作者:benwong2013 -- 发布时间:2020/2/6 15:53:00 -- 企业微信获取人员信息 根据帮助文件在获取企业微信人员信息的出现这样的问题,请问如何处理? Dim ur As String = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token={0}&department_id=1&fetch_child=1&status=0" Dim hc As New HttpClient(CExp(ur,Functions.Execute("GetQYAccessToken"))) Dim jo As JObject = JObject.Parse(hc.GetData()) If jo("errcode") = "0" Then DataTables("WXUsers").DataRows.Clear Dim nms() As String = {"userid","name","position","mobile","gender","email","weixinid","avatar","status"} \'"" For Each jt As JToken In jo("userlist") Dim dr As DataRow = DataTables("WXUsers").AddNew() For Each nm As String In nms dr(nm) = jt(nm) Next If dr("department") IsNot Nothing dr("department") = CompressJson(jt("department")).Trim("[","]") End If If jt("extattr") IsNot Nothing Then dr("extattr") = ComPressJson(jt("extattr")("attrs")).Trim("[","]") End If Next DataTables("WXUsers").Save() Else MessageBox.Show(jo.ToString) End If |
|||
-- 作者:有点蓝 -- 发布时间:2020/2/6 16:15:00 -- https://work.weixin.qq.com/api/doc/90000/90139/90313
|
|||
-- 作者:benwong2013 -- 发布时间:2020/2/6 16:22:00 -- 我已经更新了Secret 还是不行 |
|||
-- 作者:benwong2013 -- 发布时间:2020/2/6 16:23:00 -- 管理组的Secret 我已经用了重新获取的还是不行 Static CreateTime As Date \'记录最近一次生成access_token的时间 Static AccessTocken As String \'记录最近一次生成的access_tokenDim CorpID As String= "*******" \'企业号的CorpID Dim Secret As String = "***************" \'管理组的Secret Dim tp As TimeSpan = Date.Now - CreateTime 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 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 |
|||
-- 作者:有点蓝 -- 发布时间:2020/2/6 16:32:00 -- 指定的应用,没有department_id=1这个部门的权限指定的成员/部门/标签参数无权限。请确认:
2) 其它接口,需要满足配置的通讯录范围。
|