Install
openclaw skills install eoffice-api泛微 e-office 协同办公系统 OpenAPI - 用户管理、部门管理、审批流程、考勤等企业级 API
openclaw skills install eoffice-api当用户提到以下场景时使用此 skill:
本 skill 使用自定义 token 流程,与 OAuth2 类似但更简单:
获取 Token(调用 scripts/get-token.py)
python scripts/get-token.py
这会向 OA 系统发送请求,用环境变量中的 EOFFICE_AGENT_ID、EOFFICE_SECRET、EOFFICE_USER 换取访问 token。
Token 自动管理
安装 skill 后,用户需要提供以下环境变量(在 OpenClaw 配置中设置):
| 环境变量 | 必填 | 说明 | 示例 |
|---|---|---|---|
EOFFICE_BASE_URL | 是 | OA 系统部署地址 | https://oa.example.com/server |
EOFFICE_AGENT_ID | 是 | 应用 Agent ID | 100001 |
EOFFICE_SECRET | 是 | 应用密钥 | abc123def456... |
EOFFICE_USER | 是 | 用户标识(工号/账号/手机号) | admin 或 18612345678 |
如何获取凭证:
Agent ID 和 SecretEOFFICE_USERcurl -X GET "$EOFFICE_BASE_URL/api/hrm/lists" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{"page": 1, "limit": 10}'
curl -X GET "$EOFFICE_BASE_URL/api/hrm/detail/{user_id}" \
-H "Authorization: Bearer {token}"
curl -X POST "$EOFFICE_BASE_URL/api/hrm/add" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"user_accounts": "zhangsan",
"user_name": "张三",
"dept_id": 1,
"role_id": [1, 2],
"user_status": 1,
"allow_login": 1,
"wap_allow": 1,
"sex": 1
}'
curl -X POST "$EOFFICE_BASE_URL/api/hrm/edit" \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"user_id": "WV00000001",
"user_accounts": "zhangsan",
"user_name": "张三(已修改)",
"dept_id": 2,
"role_id": [1],
"user_status": 1,
"allow_login": 1,
"wap_allow": 1,
"sex": 1
}'
curl -X POST "$EOFFICE_BASE_URL/api/hrm/delete/{user_id}" \
-H "Authorization: Bearer {token}"
curl -X GET "$EOFFICE_BASE_URL/api/department/allTree" \
-H "Authorization: Bearer {token}"
curl -X GET "$EOFFICE_BASE_URL/api/department/detail/{dept_id}" \
-H "Authorization: Bearer {token}"
GET /api/hrm/lists
Body: {"search": {"user_name": ["张", "like"]}}
GET /api/department/users/{dept_id}
GET /api/hrm/superior/{user_id}
GET /api/hrm/subordinate/{user_id}
所有 API 返回格式统一:
成功:
{
"status": 1,
"data": { ... }
}
失败:
{
"status": 0,
"errors": [
{"code": "0x000003", "message": "未知错误"}
]
}
| 错误码 | 说明 |
|---|---|
0x000003 | 未知错误 |
0x500001 | 参数缺失 |
0x500002 | 应用不存在 |
0x500003 | Token 无效或已过期 |
0x500004 | 语言环境无效 |
0x500005 | 用户不存在 |
0x500006 | 用户不在白名单内 |
0x500007 | 无账号人员不支持生成 Token |
user_status 字段标识用户是否在职,离职用户通常 user_status 为特定值dept_id,可先调用部门列表 API 查询role_id 是数组,指定用户的权限角色详见 references/api.md