require_once __DIR__ . '/vendor/autoload.php';
function initializeSheets(){
$KEY_FILE_LOCATION = __DIR__ . '/service-account-credentials.json';
$client = new Google_Client();
$client->setApplicationName("Google Sheets API PHP Quickstart");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/spreadsheets']);
return $client;
}
$sheets = new Google_Service_Sheets(initializeSheets());
//создаем саму таблицу
$sfsef = new Google_Service_Sheets_GridProperties();
$sfsef->setRowCount(8);
$sfsef->setColumnCount(5);
$sheet111 = new Google_Service_Sheets_SheetProperties();
$sheet111->setSheetType('GRID');
$sheet111->setSheetId(0);
$sheet111->setTitle('название листа');
$sheet111->setGridProperties($sfsef);
$sheet = new Google_Service_Sheets_Sheet();
$sheet->setProperties($sheet111);
$properties = new Google_Service_Sheets_SpreadsheetProperties();
$properties->setTitle('название документа');
$properties->setLocale('ru_RU');
$spreadsheets1 = new Google_Service_Sheets_Spreadsheet();
$spreadsheets1->setProperties($properties);
$spreadsheets1->setSheets($sheet);
$result = $sheets->spreadsheets->create( $spreadsheets1 ) ;
//даем доступ для редактирование кому угодно
$drive = new Google_Service_Drive(initializeSheets());
$drive1 = new Google_Service_Drive_Permission();
$drive1->setType('anyone');
$drive1->setRole('writer');
$drive1s = $result['spreadsheetId'];
$resultqqq = $drive->permissions->create( $drive1s, $drive1 ) ;
echo '<pre>';
print_r($result);
echo '</pre>';
\CAgent::AddAgent( "\\Your\\Module\\SuperClass::superAgent();", "your.module", "N", 10 * 24 * 3600, "", "Y");
\CAgent::RemoveModuleAgents("your.module");