列出機構中的自訂表情符號

本指南說明如何使用 Google Chat API 的 CustomEmoji 資源中的 list 方法,列出 Google Workspace 機構中通過驗證的使用者可見的自訂表情符號。

自訂表情符號僅適用於 Google Workspace 帳戶,且管理員必須為貴機構啟用自訂表情符號。詳情請參閱「瞭解 Google Chat 中的自訂表情符號」和「管理自訂表情符號權限」。

必要條件

Node.js

列出機構中的自訂表情符號

如要列出機構中的自訂表情符號,請使用使用者驗證,並在要求中傳遞下列項目:

以下範例會列出機構中的自訂表情符號。

Node.js

chat/client-libraries/cloud/list-custom-emojis-user-cred.js
import {createClientWithUserCredentials} from './authentication-utils.js';

const USER_AUTH_OAUTH_SCOPES = ['https://www.googleapis.com/auth/chat.customemojis'];

// This sample shows how to get custom emoji with user credential
async function main() {
  // Create a client
  const chatClient = await createClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);

  // Initialize request argument(s)
  const request = {
    // Optional. Replace FILTER here
    filter: 'FILTER'
  };

  // Make the request
  const pageResult = await chatClient.listCustomEmojisAsync(request);

  // Handle the response. Iterating over pageResult will yield results and
  // resolve additional pages automatically.
  for await (const response of pageResult) {
    console.log(response);
  }
}

main().catch(console.error);

如要執行這個範例,請替換下列項目:

  • FILTER:(選填) 要套用至清單要求的篩選器。