【发布时间】:2021-04-10 10:05:46
【问题描述】:
$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();
我已经为此苦苦思索了好几个小时。我不知道为什么我不能创建一个新的 Google Doc。除了谷歌之外,网上绝对没有这样的例子,这里的大部分代码都是直接从他们那里复制而来的。
这是我在分配标题后但在执行服务以创建新文档之前打印 $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
(
)
)
【问题讨论】:
标签: php google-api google-docs google-api-php-client google-docs-api