DataTables("下载users").DataRows.Clear
Dim r As Row
Dim dr As DataRow
Dim ul As String
ul = "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(ul,Functions.Execute("GetQYAccessToken")))
Dim jo As JObject = JObject.Parse(hc.GetData())
If jo("errcode") = "0" Then
Dim nms() As String = {"userid","name","position","mobile"} '""
For Each jt As JToken In jo("userlist")
dr = DataTables("下载Users").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
Next
DataTables("下载Users").Save()
Else
End If
'DataTables("临时员工资料").LoadFilter = ""
'DataTables("临时员工资料").Load
For Each r In Tables("下载users").Rows
dr = DataTables("临时员工资料").Find("工号 = '" & r("userid") & "'")
If dr.IsNull("手机号码") = False Then
If dr("手机号码") <> r("mobile") Then
msgbox(dr("姓名0"))
ul = "https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={0}"
Dim hc1 As New HttpClient(CExp(ul,Functions.Execute("GetQYAccessToken")))
Dim jo1 As New JObject
jo1("userid") = CStr(r("userid"))
jo1("mobile") = CStr(dr("手机号码"))
hc.Content = jo.ToString
jo1 = JObject.Parse(hc1.GetData)
If jo1("errcode") = "0" Then
Else
End If
End If
End If
If dr("是否离职") = 1 Then
ul = "https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token={0}&userid={1}"
Dim hc2 As New HttpClient(CExp(ul,Functions.Execute("GetQYAccessToken"),dr("工号")))
Dim jo2 As JObject = JObject.Parse(hc2.GetData)
If jo2("errcode") = "0" Then
Else
End If
End If
Next
For Each r In Tables("临时员工资料").Rows
If r("是否离职") = 0 Then
dr = DataTables("下载users").Find("userid = '" & r("工号") & "'")
If dr Is Nothing Then
ul = "https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token={0}"
Dim hc3 As New HttpClient(CExp(ul,Functions.Execute("GetQYAccessToken")))
Dim jo3 As New JObject
jo3("userid") = CStr(r("工号"))
jo3("name") = CStr(r("姓名0"))
Dim dr1 As DataRow = DataTables("Departments").Find("[name] = '" & r("部门") & "'")
If dr1 IsNot Nothing
jo3("department") = CStr(dr1("id")) '部门ID为3和9
Else
jo3("department") = "1"
End If
jo3("mobile")= CStr(r("手机号码"))
jo3("gender") = "1"
hc.Content = Jo.ToString
jo3 = JObject.Parse(hc3.GetData)
If jo3("errcode") = "0" Then
Else
MessageBox.Show(jo3.ToString)
End If
End If
End If
Next
为什么企业号创建用户和修改用户什么的 全都失败,我用代码直接单个执行,又成功,求解?