-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_history
executable file
·51 lines (43 loc) · 1.23 KB
/
upload_history
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
50
#!/usr/bin/env php
<?php
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/googlesheets.php';
$sheet = '1pRBIrNYjw5Qp1B8DyiyeKhFPFZB0hS_L94d4pa6V6YU';
$data = json_decode($argv[1]);
$now = new DateTime();
// Get the API client and construct the service object.
$client = getGoogleClient();
$service = new Google_Service_Sheets($client);
$insert = [
'insertDimension' => [
'range' => [
'sheetId' => 0,
'dimension' => "ROWS",
'startIndex' => 1,
'endIndex' => 2
]
]
];
$batch = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest(['requests' => $insert]);
$response = $service->spreadsheets->batchUpdate($sheet, $batch);
$sheet_id = $sheet;
$range = "Musiikki!A2";
$updateBody = new Google_Service_Sheets_ValueRange([
'range' => $range,
'majorDimension' => 'ROWS',
'values' => [
[
25569 + ($now->getTimestamp() + $now->getOffset()) / 86400,
$data->show ?? '',
$data->artist ?? '',
$data->title ?? '',
]
]
]);
$service->spreadsheets_values->update(
$sheet_id,
$range,
$updateBody,
['valueInputOption' => "RAW"]
);