I'm trying to get the download source from a Google Drive file I own. I currently have this code:
$videoSRC = "https://www.googleapis.com/drive/v3/files/". $_GET['id']. "?alt=media&key=API_KEY_HERE";
echo '<video autoplay="" preload="auto" src="'. $videoSRC. '"></video>';
The problem is, when you look at the video source, it says the video source is "https://www.googleapis.com/drive/v3/files/GOOGLE_FILE_ID?alt=media&key=API_KEY_HERE". While it does display the video, I've seen that website have their video source as "https://redirector.googlevideo.com/videoplayback". How are they able to achieve this?
I suggest using the webContentLink of the file which is generated by using the Files.get.
Files.get uses the following URI request:
https://www.googleapis.com/drive/v3/files/fileId
Tried this on one of my file and got this webContentLink:
https://docs.google.com/uc?id=0Bzgk4zccNwI7MmJOYWs3SG1VUUE&export=download
You can pass this link in your GET request in PHP and see if it downloads the file.
Related
I am using Youtube download API when i click on download button video is downloading but filename showing "videoplayback.MP4"
My code:
<?php
$url="http://hddir.com/ajax/api.php?type=downlink&v=Is3S-6hHQLk";
$c=curl_init();
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
curl_setopt($c,CURLOPT_URL,$url);
$contents=curl_exec($c);
curl_close($c);
$someObject = json_decode($contents);
foreach($someObject as $obj){
$url=$obj->url;
$format=$obj->format;
echo '<a href="'.$url.'" download>video '.$format.'</a></br>';
}
?>
Result result of above code
As a quick fix, HTML5 provides a download attribute you may use in your anchor tag, this allows you to specify the desired file name of the download. This relies on the end user using a browser which supports this tag.
echo 'video '.$format.'</br>';
At the time of writing browser support is:
Chome: 14.0
Edge: 13.0
Firefox: 20.0
Safari: 10.1
Opera: 15.0
There is no requirement to specify a file extension.
More information can be found online including browser support, for example this W3 Schools Article
Update: This will not work cross-origin, the file must be hosted on the same domain, as such this is not a solution for this particular problem unfortunately.
i just written code for play videos
like this
$vid was the video file name where the videos are in www\videos folder.
read the content in the folder using the
<video src='videos/$vid'> it is working
same as i just try to play videos in some drive like g:\videos folder
$path='G:\videos\';
$video is video file name in that folder
here i written code like this <video src='$path\$video'
please tell me any solution for this
thank u
Your problem is that G:\videos is not a valid html path. Instead do this.
PHP
$path = 'file:///G:\videos';
$vid = 'filename.mp4';
HTML
<video src='<?="$path\$vid"?>'>
I'm trying to download hidden whatsapp data from Google Drive.
Thanks to Tomers useful instructions here (Thanks!) I can see the data but I'm quite flummoxed how to download it. My main problem is I can't identify a direct link and I can't get my head around the coding to request one.
Many Thanks!
Each file inside the hidden Google Drive directory has an ID, which you can see via $file->getId(). (In my example you have linked, the ID is shown in parentheses next to each file name)
Then, downloading the file should be as simple as
$fileId = '1kTFG5TmgIGTPJuVynWfhkXxLPgz32QnPJCe5jxL8dTn0';
$content = $service->files->get($fileId, array('alt' => 'media' ));
file_put_contents("result_file.crypt9",$content);
Also take a look at the documentation.
I currently have a problem to open a .ppt/.pptx file inside a webpage. I currently have all "uploaded" file in a folder and am able to open .html/.txt files in that folder, but not .ppt/.pptx. Whenever I try, a new window pops up and Windows Uploader starts to run.
<?php
$target_dir = "C:\Apache\htdocs\upload\\";
$target_file = $_FILES['file']['name'];
?>
<iframe src = "upload/"<?php echo $target_file; ?>" name = "iframe_s" id = "download" style = "display:none"></iframe>
Click here to view files
In the above code, I try to list all files in the folder, and the goal is a user can click on one of the file, then the file will open inside the webpage. The main problem I have right now is to have the program each individually attach different .ppt url to different files.
Thank you in advance!
For your question "How to upload to Google Docs".
My first Answer:Why don't you search properly???
If you still don't find it. Then, (taken from here)
You'd use the Google Documents API to upload them using a simple HTTP POST with the data. Here's an explanation how to upload and convert documents: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDocs
The link will provide you will examples and all you need to do what you were asking for.
To be more precise this is what you are looking for if you want to upload pdf's: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUploadPUT
Python Google Documents API guide
PHP Google Documents API guide
What I want to do is following:
User takes screenshot with the application like jing. ok!
Pastes link that Jing returned back. ok!
Server processes the link that user entered, and extracts images source url. But, I have no idea how server will get "clean" image source URL. For example, this is the link that Jing returned after sharing screenshot http://screencast.com/t/zxBzNNkcg but real url of image looks like http://content.screencast.com/users/TT13/folders/Jing/media/c25ec5c6-bc6a-413c-a50b-ada95fac4ed2/2012-07-25_0221.png
Server returns back image source URL. no idea!
Is there any possible way to get image url with Javascript or PHP?
you could use Simple PHP DOM Parser to retrieve the image from the url without considering the url for as long as it contains and image inside, like so:
foreach($html->find('div[class=div-that-contain-the image]') as $div) {
foreach($div->find('img') as $img){
echo "<img src='" . $img->src . "'/>";
}
}
That is my solution.
You can retrieve the page containing the image using a DOM library like Query Path.
Using that you can extract the URL to the image.
So in your step 3:
Get source of shared screenshot page (maybe use file_get_contents)
Extract screenshot's image src, using Query Path.
Return image src URL to user
Yes. If you right click on the image and go Copy Image Location, you'll see it's http://content.screencast.com/users/TT13/folders/Jing/media/c25ec5c6-bc6a-413c-a50b-ada95fac4ed2/2012-07-25_0221.png
If you were to do it programmatically, you would use cURL and simplehtmldom.sourceforge.net to parse the outputed HTML for the actual link.
Javascript answer:
Will the output image always have the same class, embeddedObject?
If so, how about something like:
myVar = document.getElementsByClassName('embeddedObject');
myVar[0].getAttribute("src");
The myVar[0] reference of course assumes that there is only ever one image on the page with the embeddedObject class, otherwise you'd need to sort, or know which index to reference each time.
Also, this sadly doesn't seem to be supported in IE8 (which browser do you need to support?):
http://caniuse.com/getelementsbyclassname