Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get view url for google docs presentation programmatically?

There has been a change in the url of google docs presentations recently:

For e.g from the URL : https://docs.google.com/present/edit?id=[docId],

to https://docs.google.com/presentation/d/[docId]/edit.

I am facing a problem due to this in my App as i was modifying the edit URL to view the Presentation in view mode by replacing 'edit' to view so the url becomes: https://docs.google.com/present/view?id=[docId],

but now to view the presentation in view mode, i need to replace 'edit' with 'preview', so that the url is https://docs.google.com/presentation/d/[docId]/preview.

but in my App i have old presentations also as well as new presentations, there i need to decide that if this an older one than replace with 'view' else 'preview' (that i can do by checking the url whether it is new or old style one). but my question is that is this way correct or is there any way in Java API through which I can directly get view/preview mode URL for a presentation. I have tried using getDocumentLink().getHref() method and also getHtmlLink().getHref() method, but both gives me the edit mode URL.

Thanks in advance!

like image 539
Ashish_cengage Avatar asked Jun 07 '26 04:06

Ashish_cengage


1 Answers

I think this is currently the only way as there is no API features that will always give you the presentation/view URL.

The closest thing you could use however is the embedLink

For instance in the Google Drive v2 API you will find:

For newer Presentations:

"alternateLink": "https://docs.google.com/presentation/d/1aJMN10R9JSWtSVBxhrW1J6v1mc3iEt91WQtyesge0N8/edit",
"embedLink": "https://docs.google.com/presentation/d/1aJMN10R9JSWtSVBxhrW1J6v1mc3iEt91WQtyesge0N8/preview",

For older presentations:

"alternateLink": "https://docs.google.com/present/edit?id=0Ad-4449Da_xrZGZtbjNuenBfMTE0ZzhudzVkaGY",
"embedLink": "https://docs.google.com/present/embed?id=0Ad-4449Da_xrZGZtbjNuenBfMTE0ZzhudzVkaGY&size=m",

Though for older presentations you will get the embed widget URL and not the presentation URL which is not as nice IMO.

This should all fix itself in theory as we are hoping to convert all of the presentations using the old system to the new system maybe some time this year (but no promises as this conversion process is quite tricky).

like image 133
Nicolas Garnier Avatar answered Jun 10 '26 07:06

Nicolas Garnier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!