ข้อมูลเบื้องต้นเกี่ยวกับ API กิจกรรม Google ไดรฟ์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Google Drive Activity API ประกอบด้วยทรัพยากร DriveActivity
ซึ่ง
แสดงถึงการเปลี่ยนแปลงที่ทำกับออบเจ็กต์ภายใน Google ไดรฟ์ของผู้ใช้ และเมธอด activity.query
ซึ่งช่วยให้คุณเรียกข้อมูลเกี่ยวกับการเปลี่ยนแปลงดังกล่าวได้
ส่งคำขอ
แอปของคุณขอข้อมูลกิจกรรมของผู้ใช้โดยใช้วิธี
activity.query
คุณขอข้อมูลกิจกรรมได้
ทั้งสำหรับรายการที่เฉพาะเจาะจงในไดรฟ์หรือสำหรับทุกอย่างที่อยู่ในโฟลเดอร์ไดรฟ์
สำหรับคำขอที่ระบุ คุณสามารถเลือกที่จะจำกัดการตอบกลับตามข้อจำกัด เช่น ช่วงเวลาหรือประเภทการดำเนินการ และคุณสามารถเลือกที่จะให้รวมกิจกรรมไว้ในการตอบกลับได้ ดูข้อมูลเพิ่มเติมได้ที่ส่งคำขอใน Drive Activity API
การตอบกลับ
การตอบกลับคำขอคือรายการกิจกรรมที่ตรงกับพารามิเตอร์ที่ระบุ
โดยที่ทรัพยากร DriveActivity
จะแสดงถึงแต่ละกิจกรรม
ทรัพยากร DriveActivity
คือคอลเล็กชันของออบเจ็กต์ Action
ซึ่งแต่ละออบเจ็กต์มีลักษณะ
เป็นแบบสแตนด์อโลนเหมือนเหตุการณ์ Action
ประกอบด้วย
ActionDetail
(เช่น Create
หรือ Edit
), Actor
(เช่น User
หรือ Administrator
), Target
(เช่น
DriveItem
หรือ Drive
) และTimestamp
หรือ TimeRange
DriveActivity
ทรัพยากรยังมี
ข้อมูลสรุป เช่น ทุก
Actor
และ
Target
จากการกระทําทั้งหมด Timestamp
หรือ TimeRange
ที่รวมเป็นหนึ่งเดียว และActionDetail
ที่สําคัญที่สุดหรือเป็นตัวแทนของ
Action
ดูข้อมูลเพิ่มเติมได้ที่รูปแบบข้อมูลของ Drive Activity API
ระดับการมองเห็นประวัติกิจกรรม
ระบบอาจไม่รายงานกิจกรรมบางอย่างในไดรฟ์เมื่อคุณใช้ API นี้ ไม่ว่า Drive Activity API จะรายงานการเปลี่ยนแปลงที่ระบุในออบเจ็กต์หรือไม่นั้นขึ้นอยู่กับว่าการเปลี่ยนแปลงหรือข้อมูลเกี่ยวกับการเปลี่ยนแปลงนั้นผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์ในแอปพลิเคชันของคุณมองเห็นหรือไม่
การมองเห็นจะขึ้นอยู่กับสิทธิ์ที่ตั้งค่าไว้สำหรับออบเจ็กต์ มีหลาย
สถานการณ์เมื่อมีการแชร์ไฟล์และโฟลเดอร์ในไดรฟ์ ดังนี้
- หากผู้เขียนแชร์เอกสาร ประวัติกิจกรรมของเอกสาร
จะไม่แสดงเฉพาะต่อผู้สร้างเท่านั้น แต่ยังแสดงต่อผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์
ซึ่งมีการแชร์เอกสารด้วย
- หากมีการแชร์เอกสารกับผู้ใช้แล้วเปลี่ยนเป็นแบบส่วนตัว ผู้ใช้ที่ได้รับการตรวจสอบสิทธิ์จะดูประวัติกิจกรรมทั้งหมดขณะที่มีสิทธิ์เข้าถึงได้ และจะเห็นว่าตอนนี้สิทธิ์ถูกจำกัดแล้ว
- หากไม่เคยมีการแชร์เอกสารกับผู้ใช้ ผู้ใช้จะดูประวัติกิจกรรมไม่ได้
เริ่มต้นใช้งาน
หากต้องการใช้ประโยชน์จาก Drive Activity API ให้ได้มากที่สุด ให้ผสานรวมแอปกับ Google Drive API ก่อน หากต้องการเริ่มต้นใช้งาน Drive Activity API ให้ดูวิธีสร้างโปรเจ็กต์และให้สิทธิ์คำขอ หรือจะเจาะลึกและอ่านเกี่ยวกับกิจกรรมในเอกสารอ้างอิง API ก็ได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-04 UTC
[null,null,["อัปเดตล่าสุด 2025-08-04 UTC"],[],[],null,["# Introduction to Google Drive Activity API\n\nThe Google Drive Activity API consists of the\n[`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource, which\nrepresents changes made to objects within a user's Google Drive, and the\n[`activity.query`](/workspace/drive/activity/v2/reference/rest/v2/activity/query) method, which allows you to retrieve\ninformation about those changes.\n\nRequest\n-------\n\nYour app requests a user's activity data using the\n[`activity.query`](/workspace/drive/activity/v2/reference/rest/v2/activity/query) method. You can request activity\neither for a specific Drive item or for everything contained under a Drive\nfolder. For a given request, you can choose to restrict the response by\n[constraints](/workspace/drive/activity/v2/requests#filters) such as time range or action type, and you\ncan choose to have the activity [consolidated](/workspace/drive/activity/v2/requests#consolidation) in the\nresponse. For more information, see [Make requests in the Drive Activity API](/workspace/drive/activity/v2/requests).\n\nResponse\n--------\n\nThe response to a request is a list of activities matching the given parameters,\nwhere a\n[`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource represents each activity:\n\nA [`DriveActivity`](/workspace/drive/activity/v2/reference/rest/v2/activity/driveactivity) resource is a collection of\n[`Action`](/workspace/drive/activity/v2/reference/rest/v2/activity/action) objects, each of which is\nself-contained like an *event* . An `Action` includes an\n[`ActionDetail`](/workspace/drive/activity/v2/reference/rest/v2/activity/actiondetail) (such as `Create`\nor `Edit`), an [`Actor`](/workspace/drive/activity/v2/reference/rest/v2/activity/actor) (such as `User`\nor `Administrator`), a [`Target`](/workspace/drive/activity/v2/reference/rest/v2/activity/target) (such\nas `DriveItem` or `Drive`), and either a\n[`Timestamp`](/protocol-buffers/docs/reference/google.protobuf#google.protobuf.Timestamp)\nor [`TimeRange`](/workspace/drive/activity/v2/reference/rest/v2/activity/timerange).\n\nA `DriveActivity` resource also contains\nsummary information, such as every\n`Actor` and\n`Target` from all the actions, a unified\n`Timestamp`\nor `TimeRange`, and either the most\nimportant or representative\n`ActionDetail` of the\n`Action`.\n\nFor more information, see the [Drive Activity API data model](/workspace/drive/activity/v2/datamodel).\n\nActivity history visibility\n---------------------------\n\nSome activity on Drive may not be reported when you use this API. Whether the\nDrive Activity API reports a given change to an object depends on whether\nthe change, or information about the change, is visible to the authenticated\nuser in your application.\n\nVisibility is based on the permissions set for the object. There's several\nscenarios when files and folders are shared in Drive:\n\n- If an author shares a document, the activity history for the document is visible to not only the creator, but also to the authenticated users with whom it was shared.\n- If a document was shared with a user and then made private, the authenticated user can see all activity history while they had access and that the permissions are now restricted.\n- If a document was never shared with a user, the user can't see any activity history.\n\nGet started\n-----------\n\nTo get the most out of the Drive Activity API, integrate your app with the\n[Google Drive API](/workspace/drive/api) first. To get started with the Drive Activity API,\nlearn how to [create a project](/workspace/drive/activity/v2/guides/project) and\n[authorize requests](/workspace/guides/configure-oauth-consent). Or, dive right in and read\nabout activities in the\n[API reference](/workspace/drive/activity/v2/reference/rest/v2/activity)."]]