取得企業基本資訊
讀取企業公開的基本資訊,例如企業名稱和 Logo。
介面資訊
| 項目 | 說明 |
|---|---|
| 介面名稱 | 取得企業基本資訊 |
| 權限標識 | enterprise.info.read(讀取企業基本資訊) |
| 請求方式 | POST / GET |
| 請求地址 | https://{gateway_host}/open/v1/enterprise/info |
| 資料格式 | application/json(POST 時)或 URL Query |
| 鑑權方式 | 應用級 access_token(需具備 enterprise.info.read 權限) |
注意:本介面的實際請求路徑以
/info結尾,末尾沒有/get。
前置條件
- 應用已在管理後臺「內部應用」中發布並啟用。
- 已取得有效的應用級
access_token。
請求參數
請求標頭
| 請求標頭 | 必填 | 說明 |
|---|---|---|
Authorization | 否 | Bearer <access_token>,建議的憑證傳遞方式;請不要與 Query 或表單方式同時使用 |
Content-Type | 否 | POST 使用 JSON 時傳入 application/json |
參數列表
本介面沒有必填的業務參數:
| 參數名 | 類型 | 必填 | 說明 |
|---|---|---|---|
access_token | string | 是 | 應用級令牌(未在 Authorization 標頭中攜帶時必填) |
targetCorpId | string | 否 | 相容性保留欄位,系統會忽略,不影響目前企業資訊的返回 |
請求範例
POST 請求:
POST https://{gateway_host}/open/v1/enterprise/info
Authorization: Bearer <access_token>
Content-Type: application/json
{}
GET 請求:
GET https://{gateway_host}/open/v1/enterprise/info
Authorization: Bearer <access_token>
回應參數
成功回應(平臺統一回應外殼):
{
"code": 200,
"msg": "",
"data": { "name": "範例企業", "logo": "https://cdn.example.com/logo.png" }
}
| 欄位 | 類型 | 說明 |
|---|---|---|
code | integer | 業務狀態碼;200 表示成功 |
msg | string | 訊息;成功時為空 |
data.name | string | 企業註冊名稱或顯示名稱 |
data.logo | string | 企業 Logo 圖片 URL;未設定時省略 |
權限與可見範圍
- 不受可見範圍影響:基本企業資訊是租戶級顯示資料,不受應用成員或部門可見範圍限制。
- 保護私有設定:私有企業設定、付款參數、安全密鑰等後臺管理資料屬於敏感內部資料,不在開放能力範圍內,本介面不會返回。
錯誤碼
鑑權與中介軟體錯誤(HTTP 狀態碼)
| HTTP 狀態碼 | msg 錯誤碼 | 說明 |
|---|---|---|
| 401 | INVALID_TOKEN | 令牌缺失、過期、撤銷,或應用不可用 |
| 403 | SCOPE_DENIED | 令牌缺少 enterprise.info.read 權限 |
| 403 | IP_DENIED | 來源 IP 不在應用安全設定的 IP 白名單中 |
業務錯誤(HTTP 200,code=500)
msg 錯誤碼 | 說明與排查建議 |
|---|---|
PERMISSION_DENIED | 應用狀態無效(已停用、未發布或已刪除) |
SERVER_ERROR | 服務端異常,請稍後重試 |
多語言呼叫範例
以下範例在服務端執行;應用密鑰和應用令牌不得下發到客戶端。
Shell
curl -sS -X GET "https://{gateway_host}/open/v1/enterprise/info" -H "Authorization: Bearer access-token-xxx"
PHP
<?php
// 生產環境應檢查 HTTP 狀態和回應體,再映射業務錯誤。
$handle = curl_init('https://{gateway_host}/open/v1/enterprise/info');
curl_setopt_array($handle, [CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => ['Authorization: Bearer access-token-xxx'], CURLOPT_RETURNTRANSFER => true]);
echo curl_exec($handle); curl_close($handle);
Golang
package main
import "net/http"
func main() {
// 令牌只在服務端請求中使用,並遵循介面的傳輸約定。
request, _ := http.NewRequest(http.MethodGet, "https://{gateway_host}/open/v1/enterprise/info", nil)
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/enterprise/info"); curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "GET");
const CURLcode result = curl_easy_perform(handle); curl_slist_free_all(headers); curl_easy_cleanup(handle); return result == CURLE_OK ? 0 : 1;
}