I have been trying to attach Google Drive Document to my php gmail api compose box.
So far I have managed to get file id on select file but can't find a proper way to how to attach that file.download url to mail box . is there any way to do so?
i also try download file using following code but showing error "Only binary file can be downloaded"
var downloadUrl = 'https://www.googleapis.com/drive/v2/files/' + file.id + '?alt=media';
//var downloadUrl2 = file.downloadUrl1;
if (downloadUrl) {
//var accessToken = gapi.auth.getToken().access_token;
//debugger;
var xhr = new XMLHttpRequest();
xhr.open('GET',downloadUrl);
debugger;
xhr.setRequestHeader('Authorization', 'Bearer ' + AUTH_TOKEN);
xhr.onload = function() {
alert(xhr.responseText);
};
xhr.onerror = function() {
alert('Error');
};
xhr.send();
} else {
alert('No Url');
}