I have a link to the google doc in this format: https://docs.google.com/document/d/googleDocId/edit
When I post it in slack or skype, these programs display me the real name of this doc:
I need to display "Test document" name on my site. Is it possible to do it only with javascript? Without creating any services on the server?
Thank you for your help!
You need to use the get
method of the Google Drive's API
which takes one required field which is the fileId
which will be 15vISe8Lw841LqdVRtZM3egniCeRcsPXtivqxuh76t6o
in your case,
To retrieve your file metadata programatically, Try this,
function printFile(fileId) {
var request = gapi.client.drive.files.get({
'fileId': fileId
});
request.execute(function(resp) {
console.log('Title: ' + resp.title);
console.log('Description: ' + resp.description);
console.log('MIME type: ' + resp.mimeType);
});
}
I have tried with your document ID, and here is the output which I had received upon a successful response,
So you can use the title
attribute to print your document tile in your site.
Hope this helps!