我们如何从 google docs api using PHP 中的 batchUpdate 请求后获得的响应中获取 HeaderId 和 FooterId?
How can we get HeaderId and FooterId from the response we get after batchUpdate request in google docs api using PHP?
我正在处理 google 文档 api。我想同时将文本插入页眉和页脚,为此我需要 header/footer id。所以,为此我首先创建了 header/footer 这样的-
$requests[] = new Google_Service_Docs_Request(array(
"createFooter" => [
"sectionBreakLocation" => [
"index" => 0,
"segmentId" => "1",
],
"type" => "DEFAULT",
],
));
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
'requests' => $requests
));
$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
在此之后,当我使用 print_r($response) 打印我的 $response 时,我可以看到我的页脚 id.Like this -
[createFooter] => Google\Service\Docs\CreateFooterResponse Object
(
[footerId] => kix.vv5nq4qsqioo
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
)
但是,在此之后我无法动态获取我的页脚 ID。我如何使用 PHP.
从此响应中获取我的页脚 ID
您可以从响应中访问 footerId
:
$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
$footerId = $response->replies[0]->createFooter->footerId;
print($footerId);
参考:
我正在处理 google 文档 api。我想同时将文本插入页眉和页脚,为此我需要 header/footer id。所以,为此我首先创建了 header/footer 这样的-
$requests[] = new Google_Service_Docs_Request(array(
"createFooter" => [
"sectionBreakLocation" => [
"index" => 0,
"segmentId" => "1",
],
"type" => "DEFAULT",
],
));
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(array(
'requests' => $requests
));
$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
在此之后,当我使用 print_r($response) 打印我的 $response 时,我可以看到我的页脚 id.Like this -
[createFooter] => Google\Service\Docs\CreateFooterResponse Object
(
[footerId] => kix.vv5nq4qsqioo
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
)
但是,在此之后我无法动态获取我的页脚 ID。我如何使用 PHP.
从此响应中获取我的页脚 ID您可以从响应中访问 footerId
:
$response = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
$footerId = $response->replies[0]->createFooter->footerId;
print($footerId);