On the Twilio blog they've posted an article from Matt Stauffer looking at the combination of Google Sheets and PHP to perform some of the normal CRUD (create, read, update, delete) operations via the Google Sheets API.
Have you ever needed to pull some data from a Google Spreadsheet? My default in the past would be to export the data and upload it to the app directly, but it turns out it’s not very difficult to read directly from Google Spreadsheets using the Google Drive API.
In this tutorial, we’ll read, write, update, and delete data from a Google Spreadsheet with just a few lines of PHP.
He clones an example spreadsheet to use in the tutorial and shows how to prepare it for programatic access (basically exposing it for use). He then gets to work using the google/apiclient and asimlqt/php-google-spreadsheet-client packages to connect to and work with the API. He includes the code to:
- connect to the API and get a usable token
- pull data from the sheet by title
- update individual cells data
- updating entire rows
- deleting rows
- insert new rows
You'll need to be a bit familiar with how the Google API Console works to get things set up, but there's an animation that helps walk you through some of it.