Skip to content

Instantly share code, notes, and snippets.

@ochui
Created December 9, 2020 11:59
Show Gist options
  • Save ochui/86e0c0b8b82ba3e211496f8fcaa0d287 to your computer and use it in GitHub Desktop.
Save ochui/86e0c0b8b82ba3e211496f8fcaa0d287 to your computer and use it in GitHub Desktop.
<?php
try {
$sSpreadsheetID = '16nfqj7V3Z4r2q4fHmiLXxmph5Ji-4Jw1BPGzYjTz3Kk';
$gclient = new \Google_Client();
$gclient->setApplicationName('Bluebot Google Sheets API PHP');
$gclient->setScopes(\Google_Service_Sheets::SPREADSHEETS);
$gclient->setAuthConfig(__DIR__.'/bluetext-adcce8c14228.json');
$gclient->setAccessType('offline');
$service = new \Google_Service_sheets($gclient);
$sheet_name = 'test123';
$body = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(array(
'requests' => array(
'addSheet' => array(
'properties' => array(
'title' => $sheet_name
)
)
)
));
$result1 = $service->spreadsheets->batchUpdate($sSpreadsheetID,$body);
} catch(Exception $ignore) {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment