-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgoog.php
More file actions
23 lines (20 loc) · 821 Bytes
/
goog.php
File metadata and controls
23 lines (20 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
require_once __DIR__ . '/vendor/autoload.php';
date_default_timezone_set("UTC");
putenv("GOOGLE_APPLICATION_CREDENTIALS=". __DIR__ . "/client_secret.json");
define('SCOPES', implode(' ', array(
Google_Service_Sheets::SPREADSHEETS)
));
if (php_sapi_name() != 'cli') {
throw new Exception('This application must be run on the command line.');
}
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setScopes(SCOPES);
$service = new Google_Service_Sheets($client);
$spreadsheetId = "1-bSPqo_BJc9xQ7SqpUmvZK7iG58lbIi5H_HIRYKNnco";
$range="data";
$valueRange= new Google_Service_Sheets_ValueRange();
$valueRange->setValues(["values" => ["x", "y"]]);
$conf = ["valueInputOption" => "RAW"];
$response = $service->spreadsheets_values->append($spreadsheetId,$range,$valueRange,$conf);