1

I have Google spreadsheet with script attached to it (with the Tools->Script Editor tool).

I want to call one of script function from external Android App. Is it possible? Should I use Spreadsheet API?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
majakthecoder
  • 177
  • 3
  • 14

2 Answers2

4

Unfortunately, you cannot directly call your script from any external application.

However, you can change it to be a web application, then invoke it via an HTTP GET or POST from almost anywhere, including an Android app.

Insert new rows into Google Spreadsheet via cURL/PHP - HOW? provides an example of a web app that you could adapt.

Should I use Spreadsheet API?

Your question doesn't actually say what it is you want to do, so the answer is "it depends". You still won't be able to invoke an embedded script using the Spreadsheet API, but you will be able to read and write spreadsheet content.

Community
  • 1
  • 1
Mogsdad
  • 44,709
  • 21
  • 151
  • 275
  • How about returning function variable to php after making post or get request? – user1788736 Mar 07 '16 at 22:15
  • 1
    @user1788736 Look at the ContentService. – Mogsdad Mar 07 '16 at 22:23
  • Thanks for reply i lookef at contentservice i mad a curl post method and i got 302 erro back from google script! I want value from google script back to php for printing it but instead i get 302 error! Any solution for it? – user1788736 Mar 09 '16 at 17:50
  • @user1788736 A 302 is probably a redirect to authenticate; either your script needs to be set to be run by anyone _even anonymous_, or you need to authenticate via OAuth. If you have more trouble, please post a new question about it. – Mogsdad Mar 09 '16 at 18:08
  • This answer needs updating (due to Execution/Apps Script API). – tehhowch Mar 27 '18 at 11:29
0

Obviously the answer depends on your usecases, but have you checked the Google Appscript API? As stated it

provides methods to remotely execute Apps Script functions

chaiyachaiya
  • 2,617
  • 18
  • 19
  • You should add some examples using the API. Bonus points if you do so in Java, as that would be most useful in context of OP's question. – tehhowch Mar 27 '18 at 11:30