I have a Google Drive File Url suppose for eg.
I want to download it to a specific folder for that i am using curl
function pickerCallback(data) {
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
var doc = data[google.picker.Response.DOCUMENTS][0];
var fileId=doc[google.picker.Document.ID];
$.ajax({
type: "POST",
url: "files/sample.php",
data: { file_id:fileId,token:oauthToken },
success: function(data)
{
}
});
}
}
sample.php
$upload_path='folder_path';
$fileId = $_POST['file_id'];
$oAuthToken = $_POST['token'];
$getUrl = 'https://www.googleapis.com/drive/v2/files/'. $fileId .'?alt=media';
$authHeader = 'Authorization: Bearer ' . $oAuthToken ;
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$returned_content = get_data($getUrl);
file_put_contents($upload_path.'/'."55dad26bf4165.jpg", $returned_content);
this is the name of the file that i am downloading 55dad26bf4165.jpg, but it gives following error :
string(379)" { "error"; { "errors":[{ "domain":"usageLimits","reason":dailyLimitExceededUnreg", message:Daily Limit for Unauthenticated Use Exceeded. Continue use requires signup.". "extendedHelp":"https://code.google.com/apisconsole" }], "code":403, "message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."}}"
Please help why this error is occuring.