Google Sheets API - Publishing HTML Form Data to a Google Sheet

Posted by Bill Thode on May 26, 2017 4:55:49 PM

Google Sheets can be a useful tool for collaboration between team members, but did you know that you can also add, edit and update content in a Google Sheet from your website or application? The Google Sheets API provides a variety of methods to interact with a sheet, and here we'll explore one of these methods step-by-step.

After configuring and enabling the Google Sheets API, we'll use the 'sheets.spreadsheets.values.append' method to publish a new row to a Google Sheet through an HTML form. To complete this project, you'll need a Google Account and a solid foundation in HTML, Javascript and PHP.

The video will walk you though the following tasks:

  1. Creating a New Project in the Google Developers Console
  2. Enabling the Google Sheets API
  3. Configuring credentials to access the API
  4. Using the Google API Explorer to create and test a sample request
  5. OAuth Credentials - Obtaining an Authorization Code, Access Token and Refresh Token (PHP)
  6. Handling the HTML form data (Javascript)
  7. Exchanging an OAuth Refresh Token for a fresh Access Token (Javascript)
  8. Calling the Google Sheets API method to post form data to the sheet (Javascript)

Resources:

Google Developers Console
https://console.developers.google.com/apis/dashboard

Google Sheets API Method Reference
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append

Google API Explorer
https://developers.google.com/apis-explorer

Download Sample Code: sgi-google-sheets-api-append.zip

If you're interested in working with the Snyder Group on a Google API development project, we're here to help. Request a Consultation »

Topics: Blog, Videos, Development