簡體   English   中英

使用 Google Apps 腳本在 Google 網站中添加/刪除編輯器

[英]Add/Remove editors in Google sites using Google Apps Script

我正在編寫一個谷歌應用程序腳本來處理一些新的谷歌網站的批量添加/刪除編輯器。 我知道谷歌應用腳本目前不支持新的谷歌網站,所以我正在嘗試使用 DriveApp 來管理編輯器。 但是該腳本不起作用並返回以下內容:

例外:服務錯誤:驅動器

每當file.addEditor()file.removeEditor()時。 我想這對新的 Google 協作平台不起作用。 還有其他解決方法嗎?

確保您在站點中使用了正確的FileId ,因為與 Google Drive 上的其他文件類型相比,獲取它並不那么簡單。 在編輯站點頁面時,可以在/d//p/之間的 URL 中找到FileId

示例: https://sites.google.com/d/????? this the file id?????/p/!!!! not here !!!!/edit https://sites.google.com/d/????? this the file id?????/p/!!!! not here !!!!/edit

我剛剛成功運行以下代碼來添加/刪除新 Google 站點的編輯器。

const zFile= DriveApp.getFileById("????? this the file id ?????");

function addEditor(){
  zFile.addEditor("pgsystemtester@gmail.com");
}

function removeEditor(){
  zFile.removeEditor("pgsystemtester@gmail.com");
}
 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM