useApplicationDefaultCredentials(); $client->addScope(Google\Service\Drive::DRIVE); $slidesService = new Google_Service_Slides($client); try { // Create a new square textbox, using the supplied element ID. $elementId = "MyTextBoxxxx_01"; $pt350 = array('magnitude' => 350, 'unit' => 'PT'); $requests = array(); $requests[] = new Google_Service_Slides_Request(array( 'createShape' => array( 'objectId' => $elementId, 'shapeType' => 'TEXT_BOX', 'elementProperties' => array( 'pageObjectId' => $pageId, 'size' => array( 'height' => $pt350, 'width' => $pt350 ), 'transform' => array( 'scaleX' => 1, 'scaleY' => 1, 'translateX' => 350, 'translateY' => 100, 'unit' => 'PT' ) ) ) )); // Insert text into the box, using the supplied element ID. $requests[] = new Google_Service_Slides_Request(array( 'insertText' => array( 'objectId' => $elementId, 'insertionIndex' => 0, 'text' => 'New Box Text Inserted!' ) )); // Execute the requests. $batchUpdateRequest = new Google_Service_Slides_BatchUpdatePresentationRequest(array( 'requests' => $requests )); $response = $slidesService->presentations->batchUpdate($presentationId, $batchUpdateRequest); $createShapeResponse = $response->getReplies()[0]->getCreateShape(); printf("Created textbox with ID: %s\n", $createShapeResponse->getObjectId()); return $response; } catch (Exception $e) { echo 'Message: ' . $e->getMessage(); } } // [END slides_create_textbox_with_text] require 'vendor/autoload.php'; createTextboxWithText('12ZqIbNsOdfGr99FQJi9mQ0zDq-Q9pdf6T3ReVBz0Lms', 'abcd1234');