how to publish to the web a spreadsheet using driv

2019-05-29 20:12发布

I activate the drive API, (V2), and I try to publish to the web a file

I try the following, but obviously, I miss something (the resource). Can somebody help me? many thanks in advance

function test(){
   var fileId = '1c5fRpKAk2YdUVzCa1LOCqDgTLZmYjsfSvTzR9BSGPYo';
   var revisions = Drive.Revisions.list(fileId);
   var items = revisions.items;
   var revisionId = items[items.length-1].id;
   var resource;
   Drive.Revisions.update( resource , fileId, revisionId).published = true;
}

1条回答
祖国的老花朵
2楼-- · 2019-05-29 20:30

several months later, we got the solution !!

//this function publish to the web the document given by ID (google sheets or docs)
function publishToWeb(){ 
var fileId = 'WqcTq4c3iumeEUSgPMCcM8yKUqycQsrn_w3XeE'; 
var revisions = Drive.Revisions.list(fileId); 
var items = revisions.items; 
var revisionId =items[items.length-1].id; 
var resource = Drive.Revisions.get(fileId, revisionId); 
resource.published = true;
resource.publishAuto = true;
resource.publishedOutsideDomain = true;
Drive.Revisions.update(resource, fileId, revisionId); 
}
查看更多
登录 后发表回答