-
Notifications
You must be signed in to change notification settings - Fork 1
/
request.php
33 lines (25 loc) · 953 Bytes
/
request.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
require_once './google-api-php-client--PHP8.2/vendor/autoload.php';
$client = new Google\Client();
// указать путь к своему json с данными сервисного аккаунта
$client->setAuthConfig('test-table-420408-3b38c4838a37.json');
$client->setApplicationName("Client_Library_Examples");
$client->addScope(['https://www.googleapis.com/auth/spreadsheets']);
$service = new Google\Service\Sheets($client);
// указать свой id таблицы
$spreadsheetId = '';
$range = 'Лист1';
$jsonData = file_get_contents('php://input');
$data = json_decode($jsonData, true);
$values = [
[$data["name"], $data["email"], $data["tg"], $data["request"]]
];
$body = new Google_Service_Sheets_ValueRange([
'values' => $values
]);
$options = [
'valueInputOption' => 'RAW'
];
$result = $service->spreadsheets_values->append($spreadsheetId, $range, $body, $options);
return http_response_code(200);
?>