-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheets.php
49 lines (42 loc) · 1.12 KB
/
sheets.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// composer require google/apiclient:^2.0
require __DIR__ . '/vendor/autoload.php';
$client = new \Google_Client();
$client->setApplicationName('Google Sheets and Bitrix24');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$client->setAuthConfig(__DIR__ . '/credentials.json');
$service = new \Google_Service_Sheets($client);
$spreadsheetId = $_ENV['SHEETS_ID'];
$range = "A2:Q";
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
if(empty($values))
{
echo "No data found";
}
else
{
foreach ($values as &$row) {
$row = array_combine([
'ID',
'TYPE',
'QUEUE',
'DOM',
'SECTION',
'FLOOR',
'NUMBER',
'STATUS',
'LAYOUT_TYPE',
'ROOMS',
'LEVEL_COUNT',
'TOTAL_AREA',
'LIVING_AREA',
'KITCHEN_AREA',
'PRICE_M2_DOLLAR',
'PRICE_M2_SUM',
'TOTAL_PRICE'
], $row);
echo "<pre>"; print_r($row); echo "</pre>";
}
}