Google Sheets and PHP

If you’d like to use the data in your Google Sheets projects from your PHP applications, this is the guide for you.

We’ll use Google’s official v4 API SDK for PHP to access an example spreadsheet inside of Google Sheets.

50 thoughts on “Google Sheets and PHP

  1. Fatal error: Uncaught GoogleServiceException: { "error": { "code": 403, "message": "Request had insufficient authentication scopes.", "errors": [ { "message": "Insufficient Permission", "domain": "global", "reason": "insufficientPermissions" } ], "status": "PERMISSION_DENIED" } }

  2. This video has been so awesome in getting me going with the PHP library, so thank you for all of the information! That said, I have a question.

    In the first example where we're simply trying to get some cells from the sheet, you call the 'GetValues()' function. In trying to use this knowledge to do other things with different API's (Drive and Photos, for example), I can't seem to use this. In my file system (within the PHP library), I'm trying to understand exactly where this 'GetValues()' method is defined, and what I would instead use in other API's. Can you offer any insight here? Thanks for your time and for the great content!

  3. Guys, it works locally, but I get error email 'Domain name not found' when deploying and it ends for me there. The funny thing is that I can't find any thread to look up what might be the issue.

  4. @twilio, firstly thank you for the great concept, have been implementing it i'm stuck at this error, trying them out, can you please help me out here, I'm trying to Read and Update(mandatory) the Data in the GoogleSheet using API with PHP
    Here is the error,
    Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 403, "message": "The request is missing a valid API key.", "errors": [ { "message": "The request is missing a valid API key.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED" } } in C:xampphtdocswwgoogleapiconnectorvendorgoogleapiclientsrcGoogleHttpREST.php:118 Stack trace: #0 C:xampphtdocswwgoogleapiconnectorvendorgoogleapiclientsrcGoogleHttpREST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttpPsr7Response), Object(GuzzleHttpPsr7Request), 'Google_Service_…') #1 C:xampphtdocswwgoogleapiconnectorvendorgoogleapiclientsrcGoogleTaskRunner.php(181): Google_Http_REST::doExecute(Object(GuzzleHttpClient), Object(GuzzleHttpPsr7Request), 'Google_Service_…') #2 C:xampphtdocswwgoogleapiconnectorvendorgoogleapiclientsrcGoogleHttpREST.php(58): Google_Task_Runner->run() #3 C:xampphtdocswwgoogleapiconnectorv in C:xampphtdocswwgoogleapiconnectorvendorgoogleapiclientsrcGoogleHttpREST.php on line 118

  5. Same as others – tried reading some online tutorials, Google documentation, Google code on Github… nothing worked until I saw your video. Short, to the point, no skipped steps. Perfect! Thanks you so much for this.

    One note – Google API is HUGE – over 200 services – and if you just need to use Sheets you can do some simple cleanup as stated here: . Very useful especially if you need to FTP these files to a server.

    Just modify your composer.json file to something like this and do the composer update

    "require": {

    "google/apiclient": "^2.7"


    "scripts": {

    "post-update-cmd": "Google_Task_Composer::cleanup"


    "extra": {

    "google/apiclient-services": [





  6. How can make it work the next function?:
    My spreadsheet is bonded with a google form wich every day is inserting new rows with a lot of data, but, there is a column wich is blank because i need to insert a verification value (maybe just like "Ok" or "this person asist the citation") in that column for every row that is inserted but i need to insert that verification value via another html form, but i dont know how to do it, because i need to put the Date when that person fillls the main form and the ID of that person and then specify to the php to insert that verification value only in the cell wich is in the same row with the Date and the ID that i put in the verification form, anyone can guide me here?

  7. Fatal error: Uncaught Google_Service_Exception: {

    "error": {

    "code": 404,

    "message": "Requested entity was not found.",

    "errors": [


    "message": "Requested entity was not found.",

    "domain": "global",

    "reason": "notFound"



    "status": "NOT_FOUND"


  8. i have a problem at 5:00, i have this error: PHP Fatal error: Uncaught GuzzleHttpExceptionRequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate can you help me pls??

Leave a Reply

Your email address will not be published. Required fields are marked *