I have an app am developing. I have been using Drive API but am stuck.Am retrieving the response body from a google doc as folows
function GetDocumentBody($file) {
$downloadUrls = $this->drive_services->files->get($file)->getExportLinks();
$downloadUrl=$downloadUrls['application/pdf'];
if ($downloadUrl) {
$request = new Google_Http_Request($downloadUrl, 'GET', null, null);
$httpRequest = $this->drive_services->getClient()->getAuth()->authenticatedRequest($request);
if ($httpRequest->getResponseHttpCode() == 200) {
//var_dump($httpRequest->getResponseBody());die();
return $httpRequest->getResponseBody();
} else {
// An error occurred.
return null;
}
} else {
// The file doesn't have any content stored on Drive.
return null;
}
}
This is my controllers
function GetDocumentBody(){
$this->cloneJob($this->driverestapis_model->downloadFile('1untELR1y30mqu61X6lHSme3VCgbaIOeF0XxMy-b0sG4'));
}
function cloneJob($data){
// Template processor instance creation
echo date('H:i:s'), ' Creating new TemplateProcessor instance...';
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('BULK/Sample_07_TemplateCloneRow.docx');
//data
$templateProcessor->setValue('data',htmlspecialchars($data));
echo date('H:i:s'), ' Saving the result document...';
$templateProcessor->saveAs('BULK/Sample_08_TemplateCloneRow.docx');
//echo getEndingNotes(array('Word2007' => 'docx'));
}
After pulling the response body displays
.PK.<[Gword/footer1.xml�V�N�0�������Э���/hU��8��x�Mc����;έ� ����C����3�����g%g[N���Ә̸f&�H��o�'d�<��F����#�W�.w�
what am i doing wrong