183 responses to “Saving Form Data to Google Spreadsheets Using PHP and the Google Docs API”

  1. drooh

    Doesn’t work. Seems like it could be a cool thing. But just like alot of other things out there, its way too much and too complicated, not for average users. If you are a rocket scientist and have alot of time to waste then this may be for you.

    I tried once on my development server and once on my main server, both gave me different errors and wasted my time.

  2. Paul

    thanks for this – works perfectly

  3. Mark

    Simple to use and works perfectly. Just download the Zend and Google zip files, unzip and make sure the correct files are in the path. Then use and smile.

  4. George

    got the basic inserts working after recompiling my apache/php to support openssl.

    On of the fields I populate to the spreadsheet is an email address. I have adapted your code to try to insert only new rows so it tries to do a check in the spreadsheet :
    $querystring = “Email=george@geolaw.com”;
    $rows = $ss->getRows($querystring);

    I have tried just about every combination on this – running it through htmlspecialchars, urlencode, etc … escaped double quotes around the email address, etc …

    Using your delete example, I wrapped my getRows with try {} and it is throwing the following exception:
    Expected response code 200, got 400 Parse error: Invalid token encountered

  5. tee

    i’m not supposed to edit anything in Google_Spreadsheet.php, right?

  6. bronson

    I got always the same error message which doesn’t mean anything to me :
    Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443. Error #808863644: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?' in /volume1/web/ZendGdata/library/Zend/Gdata/ClientLogin.php:141 Stack trace: #0 /volume1/web/master/farinspace-google-spreadsheet-0a21310/Google_Spreadsheet.php(223): Zend_Gdata_ClientLogin::getHttpClient('tartemolle@gm...', 'FFFFFF', 'wise') #1 /volume1/web/master/farinspace-google-spreadsheet-0a21310/Google_Spreadsheet.php(40): Google_Spreadsheet->login('tartemolle@gm...', 'FFFFFF') #2 /volume1/web/essaiGdata.php(15): Google_Spreadsheet->__construct('tartemolle@gm…', 'FFFFFF') #3 {main} thrown in /volume1/web/ZendGdata/library/Zend/Gdata/ClientLogin.php on line 141

    Some one knows how to manage this error ?

    Many thanks

  7. George


    You need to have the php openssl extension installed.

    So if you run your own server and you have rolled your own PHP, recompile with –with-openssl

    # ./configure –help |grep openssl
    –with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)
    –with-openssl-dir[=DIR] FTP: openssl install prefix
    –with-openssl-dir[=DIR] SNMP: openssl install prefix

    If you use the RPM versions of the PHP extensions, this is also included in the php-common RPM package.

    If you are hosted through a hosting company, ask them to enable php-openssl


  8. George Law

    RE: searching with getRows and an email address

    To update my problem with searching for an email address, I found another posting early on suggesting that you do a MD5 on the email address and then use that as an ID field – since this is plain text, the getRows() works fine.


  9. anil


    I have check for openssl.

    OpenSSL support enabled
    OpenSSL Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

    But still i am getting same error again ……

    Fatal error: Uncaught exception ‘Zend_Gdata_App_HttpException’ with message ‘Unable to Connect to ssl://www.google.com:443. Error …….

    I Spock to hosting provider they told me to give IP address of site that attempts to use…

    Anybody know the ip address that uses to connect google doc API


  10. George Law


    I forgot that some hosts block outgoing http/https as well:

    Google docs looks like they use round robin DNS across 15 different IPs.
    #> host docs.google.com
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address
    docs.google.com has address


  11. wolf3d

    Found this article with google! thank You very much for this lib, im gona build my blog app using this approach, no mysql involved :)

  12. wolf3d

    @Mark Yes I had issues with path to zend lib, I started to think that it doesnt work for me to or something else… but i fixed it and it works fine (sun)

  13. wolf3d

    @Dimas You are right, but it’s just for my research project im working on, I like to experiment!

  14. Dave Kaye

    I think it’s incredible how many people here are all like “This is impossible, you must be some kind of rocket scientist…”

    Or maybe you must be some kind of computer programmer! It’s a whole discipline and it takes time, effort, and energy to learn. Just because you’re on Facebook all day doesn’t make you a Zend developer. Sheesh. Kudos to you for accommodating these people but if this is too hard, the reason might just be that you’re not a programmer.

  15. Nick


    First of all thank you for this information! I have build quite an elaborate stock analysis spreadsheet which needs only one input, the ticker symbol, and then retrieves data from several websites and performs multiple calculations and analyses. In the end it gives a simple answer to the question “Should I buy? YES or NO?”

    I would like to build a PHP script which can input one ticker after the other in the Gdocs spreadsheet and save all the tickers which lead to a YES answer (a buy recommendation) in a separate worksheet.

    My question: is the Google spreadsheet API capable of performing these actions?

    It will save me a lot of time if I find out upfront by one of your answers whether this is possible or not. Thanks!

  16. Marc Christenfeldt

    Thank you for this!
    It works for my needs. Unfortunately there is some annyoing “bug” in this, actually the problem comes from the Zend Library itself (Zend_Gdata_Spreadsheets::updateRow) I think.
    When you have formulas in your worksheet and use the updateRow method, the formula is overwritten and the actual value of the cell is inserted instead.
    Nice class anyway.

  17. Ryan

    This is a very cool helper class! It worked for me right away. Just a question however, I’m no security expert so I’m wondering what security issues I might be exposed to by including my Google password in the page source. I know the PHP gets processed before rendering the HTML, but is there any threat short of a hacked server account that I should be worried about? Does anyone have a way to encrypt/decrypt the password in the source in case the server does get hacked?


  18. amn

    I started using this today. Few things:

    1) You need OpenSSL to use it. Check your php.ini file and uncomment


    If it does not exist, typeit in manually and make sure php_openssl.dll is in the c:/xampp/php/ext folder.

    2) If you’re using php strict and get pass by reference errors, you’ll need to change this in the Google_Spreadsheet class. You’ll need to do it twice, once for getSpreadsheetId() and once for getWorksheetId().

    $wk_id = array_pop(explode(“/”,$entry->id->text))


    $entry_array = explode(“/”,$entry->id->text);
    $wk_id = array_pop($entry_array);

    3) Errors. It seems that google docs is extremely strict with errors. If anything wrong happens, it may lock you out of the spreadsheet for 5-10 minutes, even from google docs itself. Not sure what to do about that except debug extensively before release. And pray for the best.

  19. Bharath

    Right now i am experimenting and this feature seems really cool but i am not able to get this work all the time it just submits perhaps some screen shots will be much helpful

  20. Franck

    Works great, thank you.

  21. molecule

    I had another block with the error ‘Unable to Connect to ssl’…

    It needed a change at the hsphere server:

    It appears this is an issue with zend using a function that was in our disabled functions list — stream_socket_client specifically. I have removed that from the list and the page now works. This should not be an issue to security as it is just a client function and not a listening

    Hope that helps someone.

  22. Abbas


    I was just wondering if its possible to write to a specific cell by specifying the row and column, instead of writing to the last row in the specified name. Also, thanks for the instructions. I was able to get it working right away :)