Foxtable(狐表)用户栏目专家坐堂 → 企业微信获取人员信息


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

主题:企业微信获取人员信息

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


加好友 发短信
等级:一尾狐 帖子:486 积分:4098 威望:0 精华:0 注册:2015/12/16 8:22:00
企业微信获取人员信息  发帖心情 Post By: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

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20200206154952.png
图片点击可在新窗口打开查看



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


加好友 发短信
等级:一尾狐 帖子:486 积分:4098 威望:0 精华:0 注册:2015/12/16 8:22:00
  发帖心情 Post By:2020/2/6 16:22:00 [显示全部帖子]

 我已经更新了Secret 还是不行

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


加好友 发短信
等级:一尾狐 帖子:486 积分:4098 威望:0 精华:0 注册:2015/12/16 8:22:00
  发帖心情 Post By:2020/2/6 16:23:00 [显示全部帖子]

管理组的Secret 我已经用了重新获取的还是不行
Static CreateTime As Date '记录最近一次生成access_token的时间
Static AccessTocken As String '记录最近一次生成的access_token
Dim 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

 回到顶部