从钉钉后台API获取企业通信录

xiaoxiao2021-02-28  8

现在很多企业都在使用钉钉办公,这样一来从钉钉获取最新的企业通讯录就非常方便,钉钉开放平台有关于开发的很多介绍。

//获取部门成员 public static List<contacts> getDepartmentUser() throws Exception{ try { String accessToken = AuthHelper.getAccessToken(); String parentId = "1";//钉钉默认 parentId = "1" List<contacts> contacts_lists=new ArrayList<contacts>(); List<Department> list = DepartmentHelper.listDepartments(accessToken, parentId); for(int k=0;k<list.size();k++) { CorpUserList userList = UserHelper.getDepartmentUser(AuthHelper.getAccessToken(), list.get(k).getId(), null, null, null); for (int i = 0; i < userList.getUserlist().size(); i++) { contacts contacts=new contacts(); contacts.setDepa(list.get(k).getName().toString()); contacts.setUserid(userList.getUserlist().get(i).getUserid()); contacts.setName(userList.getUserlist().get(i).getName()); contacts_lists.add(contacts); } } return contacts_lists; } catch (OApiException e) { e.printStackTrace(); } return null; } public class contacts { private String userid;//用户唯一标识 private String name; private String depa;//所属部门 public String getUserid() { return userid; } public void setUserid(String userid) { this.userid = userid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDepa() { return depa; } public void setDepa(String depa) { this.depa = depa; } }
转载请注明原文地址: https://www.6miu.com/read-2150212.html

最新回复(0)