1
  1. I have a PHP app deployed in GAE(Google App Engine)

  2. I need to connect to Google Docs, Google Spreadsheet URL below and do all editions/manage(edit a Doc, Edit a Sheet,...etc) as like I am able to do via GAS, just like we manage the CAL API.

    https://developers.google.com/apps-script/reference/document/ https://developers.google.com/apps-script/reference/spreadsheet/

  3. What is the best approach for it? How to use those functions available in GAS via PHP GAE?

    Plz someone help, a small tip would also help us.

Community
  • 1
  • 1
Sattanathan
  • 453
  • 9
  • 24
  • Google APIs client library: https://github.com/google/google-api-php-client – Mars May 25 '15 at 18:29
  • Thnks Mars fr the PHP Client API. Can I also use the Class Document App(GAS) from this API or only G Sheets API, coz Document Service does not have a proper API. – Sattanathan May 26 '15 at 05:09
  • that last question in the comment is already answered on s.o. look at calling apps script as a content service. – Zig Mandel May 26 '15 at 13:28

1 Answers1

3

In PHP, you can make an HTTP Request. In Apps Script, you can create a Stand Alone Apps Script project, that detects either a GET or POST request, and runs code. Then the code can do whatever you want it to do (E.g. write data to spreadsheet). When the code is done, you can have it return something back to the PHP code that called it.

So, you can use an Apps Script project as an intermediary between your PHP and a Google spreadsheet. This avoids needing to use the PHP API for Google Spreadsheets. The Apps Script file is an intermediary between your PHP code and getting data written/read from your spreadsheet. But an API is also an intermediary. So, in that sense it's the same. If you already have Apps Script code that does what you want, you can trigger it to run with a doGet() or doPost() function. And you can avoid learning the API.

For more information see the following post:

stackoverflow answer - Call a custom GAS function from external URL

Alan Wells
  • 30,746
  • 15
  • 104
  • 152
  • Thnks fr ur reply Sandy. I already have my GAS script, which does all the operations using Document App and Spreadsheet Service. But are you telling that I can use my PHP to call this intermediate script to do my operations w/o calling PHP API? If yes ,what are the steps? Plz clarify it? Many Thnks in advance, – Sattanathan May 26 '15 at 05:10
  • Thanks lot Sandy & others. Now i m using this method – Sattanathan May 27 '15 at 03:38