以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  通过手机号获取企业微信通讯录信息  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=173632)

--  作者:jiushian
--  发布时间:2021/12/9 9:21:00
--  通过手机号获取企业微信通讯录信息
我想通过手机号获取企业微信通讯录信息,不通过userid怎么实现?下面代码报错。

\'Dim ul As String  = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&userid={1}"
\'ul= CExp(ul,Functions.Execute("GetQYAccessToken"),UserId)


Dim ul As String  = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={0}&mobile={1}"
ul= CExp(ul,Functions.Execute("GetQYAccessToken"),mobile)

--  作者:有点蓝
--  发布时间:2021/12/9 9:33:00
--  
我没看到企业微信有提供通过手机号获取成员的接口,您的接口是从哪里找的,文档发过来看看。

通常提供的接口都是固定的用法,不是随便可以更改的

--  作者:jiushian
--  发布时间:2021/12/9 16:09:00
--  
我自己加上的,理解错了。下面代码这样写可以获取到mobile手机号吗?想通过手机号验证。


If e.GetValues.ContainsKey("code") Then \'如果通过授权链接跳转而来,就根据传递过来的code参数调用接口,获取用户的UserId
    Dim ul As String  = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={0}&code={1}"
    ul = CExp(ul,Functions.Execute("GetQYAccessToken"),e.GetValues("code"))
    Dim hc As new HttpClient(ul)
    Dim jo As JObject = JObject.Parse(hc.GetData)
    \'If jo("UserId") IsNot Nothing Then
    If jo("mobile") IsNot Nothing Then
        \'UserId = jo("UserId")
        mobile = jo("mobile")
    End If
Else
    \'UserId = e.Cookies("uid")  
    mobile = e.Cookies("mobile")
End If

--  作者:有点蓝
--  发布时间:2021/12/9 16:18:00
--  
接口会返回什么内容请去看企业微信的开发文档。