跳至主要内容

取得成員詳情

取得指定企業成員的詳細資訊。

介面資訊​

項目說明
介面名稱取得成員詳情
權限標識contact.user.read(讀取成員基本資訊)
請求方式POST / GET
請求地址https://{gateway_host}/open/v1/contact/user/get
資料格式application/json(POST 時)或 URL Query
鑑權方式應用級 access_token(需具備 contact.user.read 權限)

前置條件​

  1. 應用已在管理後臺「內部應用」中發布並啟用。
  2. 已取得有效的應用級 access_token。
  3. 目標成員必須存在、狀態正常,且在應用的可見範圍內。

請求參數​

請求標頭​

請求標頭必填說明
Authorization否Bearer <access_token>,建議的憑證傳遞方式;請不要與 Query 或表單方式同時使用
Content-Type否POST 使用 JSON 時傳入 application/json

參數列表​

參數可放在 POST JSON Body、POST Form 表單或 GET Query 中:

參數名類型必填說明
access_tokenstring是應用級令牌(未在 Authorization 標頭中攜帶時必填)
useridstring是目標成員使用者 ID(正整數字串)。系統相容別名 userId、user_id
languagestring否語言/國際化保留參數,目前不影響返回內容

請求範例​

POST 請求:

POST https://{gateway_host}/open/v1/contact/user/get
Authorization: Bearer <access_token>
Content-Type: application/json

{ "userid": "42" }

GET 請求:

GET https://{gateway_host}/open/v1/contact/user/get?userid=42
Authorization: Bearer <access_token>

回應參數​

{
"code": 200,
"msg": "",
"data": {
"userId": "42", "name": "張三", "avatar": "https://cdn.example.com/avatar/42.png",
"mobile": "13800000000", "email": "zhangsan@example.com", "jobNumber": "A-001",
"title": "工程師", "deptIdList": ["10", "20"]
}
}
欄位類型說明
codeinteger業務狀態碼;200 表示成功
msgstring訊息;成功時為空
data.userIdstring成員 ID,以字串返回以避免大數精度損失
data.namestring成員暱稱/姓名
data.avatarstring成員頭像 URL;未設定時省略
data.mobilestring手機號碼;未設定時省略
data.emailstring電子郵件;未設定時省略
data.jobNumberstring工號;未設定時省略
data.titlestring職稱;未設定時省略
data.deptIdListstring[]成員所屬部門 ID 列表(僅包含應用可見範圍內的部門);無資料時為 []

權限與可見範圍過濾​

  1. 可見範圍限制:應用只能讀取自己可見範圍內的成員資料。
  2. 資料遮罩與保護:內部標記、角色權限設定等管理欄位不會返回。
  3. 不存在與不可見等價:目標成員不存在、已停用/刪除或超出應用目前可見範圍時,介面統一返回 USER_NOT_FOUND,避免洩漏企業組織結構。

錯誤碼​

HTTP 狀態碼msg 錯誤碼說明
401INVALID_TOKEN令牌缺失、過期、撤銷,或應用不可用
403SCOPE_DENIED令牌缺少 contact.user.read 權限
403IP_DENIED來源 IP 不在應用安全設定的 IP 白名單中
200 / code=500INVALID_REQUESTuserid 缺失、為空或不是合法的正整數字串
200 / code=500USER_NOT_FOUND成員不存在、已停用/刪除,或超出應用可見範圍
200 / code=500PERMISSION_DENIED應用狀態無效(已停用、未發布或已刪除)
200 / code=500SERVER_ERROR服務端異常,請稍後重試

多語言呼叫範例​

以下範例在服務端執行;應用密鑰和令牌不得下發到客戶端。

Shell​

curl -sS -X POST "https://{gateway_host}/open/v1/contact/user/get" -H "Authorization: Bearer access-token-xxx" -H "Content-Type: application/json" -d '{"userid":"42"}'

PHP​

<?php
// 生產環境應檢查 HTTP 狀態和回應體,再映射業務錯誤。
$handle = curl_init('https://{gateway_host}/open/v1/contact/user/get');
curl_setopt_array($handle, [CURLOPT_POST => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer access-token-xxx', 'Content-Type: application/json'], CURLOPT_POSTFIELDS => '{"userid":"42"}', CURLOPT_RETURNTRANSFER => true]);
echo curl_exec($handle); curl_close($handle);

Golang​

package main
import ("bytes"; "net/http")
func main() {
// 令牌只在服務端請求中使用,並遵循介面的傳輸約定。
request, _ := http.NewRequest(http.MethodPost, "https://{gateway_host}/open/v1/contact/user/get", bytes.NewBufferString(`{"userid":"42"}`)); request.Header.Set("Authorization", "Bearer access-token-xxx"); response, _ := http.DefaultClient.Do(request); defer response.Body.Close()
}

C++​

#include <curl/curl.h>
int main() {
// 生產環境應啟用 TLS 校驗並處理 HTTP 錯誤。
CURL* handle = curl_easy_init(); struct curl_slist* headers = curl_slist_append(nullptr, "Authorization: Bearer access-token-xxx"); curl_easy_setopt(handle, CURLOPT_URL, "https://{gateway_host}/open/v1/contact/user/get"); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handle, CURLOPT_POSTFIELDS, R"({"userid":"42"})"); const CURLcode result = curl_easy_perform(handle); curl_slist_free_all(headers); curl_easy_cleanup(handle); return result == CURLE_OK ? 0 : 1;
}