1

I am new to google developer's api, my goal is to download google slide from google drive to my server with raw request in php only not with the pdk sdk. I have done the following step:

1) I got access_token by authenticate process by giving all the mandatory scope.

2) Now i go to https://www.googleapis.com/drive/v2/files/FILEID to get file metadata in response i get the exportLinks array() in that i get the download slide url by which i can get the slide from google drive to my server. Suppose below is the final exportLinks which i want

https://docs.google.com/feeds/download/presentations/Export?id=MYFILEID&exportFormat=pptx

If i hit above URL in the browser the valid file is downloading Now the actual problem comes i code to download file from above url to my server like below:

<?php 

$c = file_get_contents("https://docs.google.com/feeds/download/presentations/Export?id=MYFILEID&exportFormat=pptx");

file_put_contents('new.pptx', $c);

Now the file new.pptx is creating on my server which is invalid means the size is incorrect about 75kb actuall size is about 11mb and also it is not opening in the powerpoint showing error like unreadable content found

Please help me how can i download valid google slide from google drive to my server..

I did Research and came to the point that if you have to download the google slide from google drive to your server so point to the exportLinks am i right here ?

May be my way is not correct, so please correct me.

lazyCoder
  • 2,544
  • 3
  • 22
  • 41
  • I can download from the endpoint using curl when the slide file is shared. Although I don't know whether this leads to the solution, can you confirm and try as follows? 1. Can we ask you about the new.pptx with the size of 75 kb? I think that new.pptx may be a HTML file. If It's so, the error message may be included, if you open it using text editor. Can we know the error? 2. Can you try to download the slide with the small size as a sample? If the size is the reason of problem, I thought that the situation may be changed. If these are not useful for you, I'm sorry. – Tanaike Nov 23 '17 at 01:40
  • @Tanaike thanks but when i call `file_get_contents("https://docs.google.com/feeds/download/presentations/Export?id=MYFILEID&exportFormat=pptx");` then yes it gives me the `html code` but it is happening for all size slide. but please correct me is it right way to download slide to our server from `exportLinks` that i am doing above – lazyCoder Nov 23 '17 at 03:10
  • Could you confirm the error message in the html code? Or are there no errors? – Tanaike Nov 23 '17 at 05:31
  • @Tanaike thanks i got the issue i was directly access the exportLinks instead of this i tried with the accesstoken it worked for me – lazyCoder Nov 23 '17 at 09:04
  • 1
    Thank you for your additional information. I'm glad your problem was solved. – Tanaike Nov 23 '17 at 11:28

1 Answers1

0

I got the issue where i was wrong, i was accessing the exportLinks directly but it should have accessed by the access token in the header with Curl thanks @ Tanaike

lazyCoder
  • 2,544
  • 3
  • 22
  • 41