F
F
FaTaLcheG2019-06-04 14:26:48
PHP
FaTaLcheG, 2019-06-04 14:26:48

Google sheets API do I understand Authorization correctly?

There is a MySql table, I just want to transfer data from it to Google sheets, but I got confused with Google_Client.
Can I use only the API key for this?
Using API Keys
https://developers.google.com/api-client-library/p...

When calling APIs that do not access private user data, you can use simple API keys.

my code is not working for the example, at least get the cell values.
require_once __DIR__ . '/vendor/autoload.php';

$client = getClient();

$service = new Google_Service_Sheets($client);

// The ID of the spreadsheet to retrieve data from.
$spreadsheetId = 'id моего файла excel';  // TODO: Update placeholder value.

// The A1 notation of the values to retrieve.
$range = 'имя страницы excel';  // TODO: Update placeholder value.

$response = $service->spreadsheets_values->get($spreadsheetId, $range);

// TODO: Change code below to process the `response` object:
echo '<pre>', var_export($response, true), '</pre>', "\n";

function getClient() {
  $client = new Google_Client();
  $client->setApplicationName("Client_Library_Examples");
  $client->setDeveloperKey("мой api key");
  return $client;
}
?>

using quickstart.php
https://developers.google.com/sheets/api/quickstar...
everything turned out easy, but I want to figure out how to do it through console.developers.google.com/apis by creating an api key there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Noir, 2019-06-04
@PolarBearGG

https://console.developers.google.com/apis/credentials
clicking Create credentials > API key in Console

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question