ส่วนรายการ

คู่มือนี้อธิบายวิธีใช้เมธอด list ในทรัพยากร Section ของ Google Chat API เพื่อแสดงรายการส่วนที่ผู้ใช้ที่ผ่านการตรวจสอบสิทธิ์ใช้ได้ใน Google Chat

ดูข้อมูลเพิ่มเติมได้ที่ สร้างและจัดระเบียบส่วนต่างๆ ใน Google Chat

ข้อกำหนดเบื้องต้น

Python

แสดงรายการส่วน

หากต้องการแสดงรายการส่วนด้วย การตรวจสอบสิทธิ์ผู้ใช้ ให้ส่งข้อมูลต่อไปนี้ในคำขอ

  • ระบุขอบเขตการให้สิทธิ์ chat.users.sections หรือ chat.users.sections.readonly
  • เรียกใช้เมธอด ListSections
  • ตั้งค่า parent เป็น users/me

ตัวอย่างต่อไปนี้แสดงรายการส่วน

Python

from google.cloud import chat_v1

def list_sections():
    # Create a client
    client = chat_v1.ChatServiceClient()

    # Initialize request
    request = chat_v1.ListSectionsRequest(
        parent="users/me"
    )

    # Make the request
    page_result = client.list_sections(request=request)

    # Handle the response
    for section in page_result:
        print(section)

Chat API จะแสดงรายการทรัพยากร Section