Enter this command in a terminal:
composer require google/apiclient:^2.0
- Go to Console developers
- Create a new project
- Enter a name
- Go to the library
- Search for "Google sheets API"
- Click on enable
- Go to Console developers
- Select the new project
- Go to the identifiers/login
- Click on "Create identifiers" → "Service account key"
- Enter "New service account" and for role select "Project : Owner" and for "Key type" select "JSON"
- Retrieve the JSON file, rename it to
credentials.json
and place it at the root of the project
- Replace the variable $spreadsheetId and $newRow and $applicationName
- And start it with
php sheets.php
The credentials.json file must be replaced with the generated file at Console Developers