$client->setAccessToken($_SESSION['access_token']);
$service = new Google_Service_Docs($client);
$title = $_SESSION['class'].' - '.date("Y-m-d");
$document = new Google_Service_Docs_Document(array(
'title' => $title
));
//everything works until here. For some reason, this line doesn't run. It doesn't even proceed.
$document = $service->documents->create($document);
//this line isn't even printed
print_r("success!");
$documentId = $document->documentId;
header('Location: https://docs.google.com/document/d/'.$documentId);
exit();
I've been scratching my head over this for hours. I have no idea why I can't create a new Google Doc. There's absolutely no examples of this online other than from Google and most of the code here is copied straight from them.
This is what I get when I print $document
after assigning the title but before executing the service to create a new document.
Google_Service_Docs_Document Object
(
[bodyType:protected] => Google_Service_Docs_Body
[bodyDataType:protected] =>
[documentId] =>
[documentStyleType:protected] => Google_Service_Docs_DocumentStyle
[documentStyleDataType:protected] =>
[footersType:protected] => Google_Service_Docs_Footer
[footersDataType:protected] => map
[footnotesType:protected] => Google_Service_Docs_Footnote
[footnotesDataType:protected] => map
[headersType:protected] => Google_Service_Docs_Header
[headersDataType:protected] => map
[inlineObjectsType:protected] => Google_Service_Docs_InlineObject
[inlineObjectsDataType:protected] => map
[listsType:protected] => Google_Service_Docs_DocsList
[listsDataType:protected] => map
[namedRangesType:protected] => Google_Service_Docs_NamedRanges
[namedRangesDataType:protected] => map
[namedStylesType:protected] => Google_Service_Docs_NamedStyles
[namedStylesDataType:protected] =>
[positionedObjectsType:protected] => Google_Service_Docs_PositionedObject
[positionedObjectsDataType:protected] => map
[revisionId] =>
[suggestedDocumentStyleChangesType:protected] => Google_Service_Docs_SuggestedDocumentStyle
[suggestedDocumentStyleChangesDataType:protected] => map
[suggestedNamedStylesChangesType:protected] => Google_Service_Docs_SuggestedNamedStyles
[suggestedNamedStylesChangesDataType:protected] => map
[suggestionsViewMode] =>
[title] => Computer 9 - Charity - 2021-01-04
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)