יצירת פרטי כניסה של מזהה לקוח OAuth לאפליקציה למחשב. כדי להריץ את הדוגמה במדריך הזה, שומרים את פרטי הכניסה כקובץ JSON בשם client_secrets.json בספרייה המקומית.
לקבלת הדרכה, יש לבצע את השלבים להגדרת הסביבה שמפורטים במדריך למתחילים הזה.
import{createClientWithUserCredentials}from'./authentication-utils.js';constUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.messages.reactions.readonly'];// This sample shows how to list reactions to a message with user credentialasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Replace SPACE_NAME and MESSAGE_NAME here.parent:'spaces/SPACE_NAME/messages/MESSAGE_NAME'};// Make the requestconstpageResult=chatClient.listReactionsAsync(request);// Handle the response. Iterating over pageResult will yield results and// resolve additional pages automatically.forawait(constresponseofpageResult){console.log(response);}}main().catch(console.error);
כדי להריץ את הדוגמה הזו, מחליפים את הפרטים הבאים:
SPACE_NAME: המזהה מ-name של המרחב המשותף.
אפשר לקבל את המזהה על ידי קריאה ל-method ListSpaces() או מכתובת ה-URL של המרחב המשותף.
MESSAGE_NAME: המזהה מ-name של ההודעה.
אפשר לקבל את המזהה מגוף התגובה שמוחזר אחרי יצירת הודעה באופן אסינכררוני באמצעות Chat API, או באמצעות השם המותאם אישית שהוקצה להודעה בזמן היצירה.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-02-14 (שעון UTC)."],[[["This guide explains how to use the `list()` method to retrieve reactions (e.g., 👍, 🚲, 🌞) for messages in Google Chat using the Google Chat API."],["Before you begin, ensure you have a Google Workspace account, set up a Google Cloud project, enable the Google Chat API, and install the Node.js Cloud Client Library."],["To list reactions, call the `ListReactions()` method, providing the message's resource name and specifying the necessary authorization scope."],["You'll need the space ID and message ID to construct the resource name for the `ListReactions()` method call."],["The Chat API returns a paginated list of reactions for the specified message."]]],["This guide details listing reactions (emojis like 👍, 🚲, 🌞) on Google Chat messages using the Chat API's `ListReactions()` method. Key actions include setting up a Google Cloud project, enabling the Chat API, and obtaining OAuth credentials. To list reactions, specify the appropriate authorization scope (`chat.messages.reactions.readonly`, etc.) and call `ListReactions()`, passing the message's resource name as the `parent`. The API returns a paginated list of reactions.\n"]]