我经常收到此错误“未定义DocumentApp”。我正在使用驱动器api与谷歌驱动器。当我尝试使用
获取当前打开的Google文档时 DocumentApp.openById('My-file-Id');
但我不断收到此错误“ documentApp未定义”。请帮我解决或者告诉我正确的方法。
function printFile(fileId)
{
$("#demo_scope").collapse('show');
var response_data = '<span class="custome_span_text"><center><img src="<?php echo base_url("img/loading.gif");?> "> Wait open the document ...</center></span>';
$("#google_drive_iframe").show();
$("#google_drive_iframe").html(response_data);
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp)
{
if(resp.code != 404)
{
file = resp;
var file_id = file.id;
var some_magic = DocumentApp.openById('My-file-Id'); <!-- Here i am getting error -->
var file_title = file.title;
var file_modifiedDate = new Date(file.modifiedDate);
var exportLinks = file.exportLinks;
var exportLink_html = exportLinks["text/html"];
$("#google_doc_filenm").val(file_title);
$("#doc_file_id").val(file_id);
$("#google_drive_iframe").show();
$("#google_drive_iframe").html('<iframe src="'+file.alternateLink+'" onclick="checkFocus();" class="google_iframe"></iframe>');
}
else
{
$("#google_drive_iframe").html("<center><span class='error_title'><i class='glyphicon glyphicon-remove'></i> Google Document has been not available !</span></center>");
alertify.error("Please select google document");
return false;
}
});
}