3

I have an existing Google Spreadsheet with a certain ID (seen in the URL).

I would like to add rows to it from a PHP script with simple code.

I would prefer not having to add huge libraries to do this. Is it possible to do this using just CURL or some small library?

What is the simplest way to do this?

forthrin
  • 2,709
  • 3
  • 28
  • 50
  • https://developers.google.com/google-apps/spreadsheets/ –  Mar 20 '13 at 20:25
  • Do you want the simplest way to do this or the way without using the supplied libraries? You can't have both. – Captain Payalytic Mar 20 '13 at 20:26
  • what does it matter if you have to add huge libraries? I don't understand your logic there. – Ryan Mar 20 '13 at 20:27
  • @Dagon: This is Java code. I'm looking for PHP. – forthrin Mar 20 '13 at 20:56
  • @CaptainPayalytic: I guess it depends. Do you have suggestions for both scenarios? – forthrin Mar 20 '13 at 20:56
  • @RPM: It seems silly to add 10k+ lines of code just to add a row to a spreadsheet. If I must, I will do it. But I wanted to ask if there was a lightweight solution. – forthrin Mar 20 '13 at 20:57
  • For the simplest way to do it you search google for "google spreadsheets api php" and from the links there you download the zend library and follow the instructions. For the way without the libraries to pore through the api code and work it all out yourself. – Captain Payalytic Mar 20 '13 at 21:23

1 Answers1

1

Options:

1) Use google apps script (java script) to create a web app that inserts the row. Then to insert the row, use the url. You can pass parameters to the app in the url.

2) there is Zend, see: Writing to Google Docs Spreadsheet using PHP I think it has an append row function, rather than an insert row, but I might be wrong. (I would like to know if you find an insert row). It uses (gdata) spreadsheet API (there is an open issue for insert row, at the moment you can only append rows)

Note, for inserting a row, I suspect option 1 is less work than option 2.

Community
  • 1
  • 1
eddyparkinson
  • 3,680
  • 4
  • 26
  • 52
  • With Option 1 you'll have to be careful with Cross-Domain Origin issues. See [If Cross Domain Ajax calls are not allowed then how are you supposed to use the google Spreadsheet API](http://stackoverflow.com/questions/8937848/if-cross-domain-ajax-calls-are-not-allowed-then-how-are-you-supposed-to-use-the). I'd recommend Option 2. – Josh Mar 21 '13 at 10:07
  • @eddyparkinson: What is the difference between "inserting" and "appending"? – forthrin Mar 21 '13 at 14:16
  • I'm not Eddy, but "inserting" is putting a new line in between specific existing lines, while "appending" is just adding one to the end of the spreadsheet. – Josh Mar 21 '13 at 16:30
  • UPDATE: I don't think that the Zend library, as mentioned in the link, exists (at least Google is not providing it). – Mike Warren Dec 15 '14 at 06:34
  • The Spreadsheet-API (Gdata) lets you use sockets, Zend is some code that uses the sockets. The gdata part of zend looks to be un-maintained, but I have not seen any reports or errors. http://framework.zend.com/manual/1.12/en/zend.gdata.spreadsheets.html – eddyparkinson Dec 15 '14 at 07:36
  • @Josh that is not related, as google-apps-script is server side, it runs on google servers. That link has nothing to do with option 1. No worries. – eddyparkinson Dec 15 '14 at 08:59