Created
September 22, 2015 06:51
-
-
Save briedis/797ecd2eaef458573d15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = 'https://www.googleapis.com/drive/v2/files/' . urlencode($_POST['googleFileId']) . '?alt=media'; | |
$oAuthToken = $_POST['oAuthToken']; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
// If google drive file download, we need the token | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $oAuthToken]); | |
$data = curl_exec($ch); | |
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
$error = curl_errno($ch); | |
curl_close($ch); | |
file_put_contents('filename.jpg', $data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks you