通讯录

$config = [
    'corp_id' => 'xxxxxxxxxxxxxxxxx',
    'secret'   => 'xxxxxxxxxx', // 通讯录的 secret
    //...
];

$contacts = Factory::work($config);

成员管理

创建成员

$data = [
    "userid" => "overtrue",
    "name" => "超哥",
    "english_name" => "overtrue"
    "mobile" => "1818888888",
];
$contacts->user->create($data);

读取成员

$contacts->user->get('overtrue');

更新成员

$contacts->user->update('overtrue', [
    "isleader": 0,
    'position' => 'PHP 酱油工程师',
    //...
]);

删除成员

$contacts->user->delete('overtrue');
// 或者删除多个
$contacts->user->delete(['overtrue', 'zhangsan', 'wangwu']);

获取部门成员

$contacts->user->getDepartmentUsers($departmentId);
// 递归获取子部门下面的成员
$contacts->user->getDepartmentUsers($departmentId, true);

获取部门成员详情

$contacts->user->getDetailedDepartmentUsers($departmentId);
// 递归获取子部门下面的成员
$contacts->user->getDetailedDepartmentUsers($departmentId, true);

用户 ID 转为 openid

$contacts->user->userIdToOpenid($userId);
// 或者指定应用 ID
$contacts->user->userIdToOpenid($userId, $agentId);

openid 转为用户 ID

$contacts->user->openidToUserId($openid);

二次验证

企业在成员验证成功后,调用如下接口即可让成员加入成功

$contacts->user->accept($userId);

部门管理

创建部门

$contacts->department->create([
        'name' => '广州研发中心',
        'parentid' => 1,
        'order' => 1,
        'id' => 2,
    ]);

更新部门

$contacts->department->update($id, [
        'name' => '广州研发中心',
        'parentid' => 1,
        'order' => 1,
    ]);

删除部门

$contacts->department->delete($id);

获取部门列表

$contacts->department->list();
// 获取指定部门及其下的子部门
$contacts->department->list($id);

标签管理

创建标签

$contacts->tag->create($tagName, $tagId);

更新标签名字

$contacts->tag->update($tagId, $tagName);

删除标签

$contacts->tag->delete($tagId);

获取标签列表

$contacts->tag->list();

获取标签成员(标签详情)

$contacts->tag->get($tagId);

增加标签成员

$contacts->tag->tagUsers($tagId, [$userId1, $userId2, ...]);

// 指定部门
$contacts->tag->tagDepartments($tagId, [$departmentId1, $departmentId2, ...]);

删除标签成员

$contacts->tag->untagUsers($tagId, [$userId1, $userId2, ...]);

// 指定部门
$contacts->tag->untagDepartments($tagId, [$departmentId1, $departmentId2, ...]);