M
M
Michael2019-02-08 21:17:42
Google Apps Script
Michael, 2019-02-08 21:17:42

Google forms POST or api?

Hello.
There is a task: every hour (at the beginning of the hour), disable access to the form.
I plan to do this not on a schedule, but at the same time before executing the python code, and open access at the end of the script.
The question is, what is the easiest way to implement this?
- I have already tried to use the plugins of the google forms itself, but as a rule, you can configure only one action there, and then it is rigidly tied to the date and time, in my case there will be situations when the script is turned off.
- The API, as I understand it, works on javascript, which, alas, I don’t know yet (but if you throw off code examples that implement access control, I will be extremely grateful)
So I have only hopes for the good old POST requests through, for example, request. But alas, I did not find any documentation on working with forms in this way. I myself tried to study browser requests, I only realized that in addition to cookies, there is also sid. Here is an example request body to enable and disable (permissions to use the form)

[{"commands":,"sid":"7ec066ecd2aebde8","reqId":0}]
[{"commands":,"sid":"7ec066ecd2aebde8","reqId":1}]

And after refreshing the page:
[{"commands":,"sid":"2f52607833384d49","reqId":0}]

I generally keep quiet about the title of the url itself, there is such a fierce sheet of xsh, tokken, and hell knows what else))
In general, I will be glad for any advice on how exactly this action can be implemented.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2019-02-08
@oshliaer

The only "correct" way to manage Forms at the moment is using Google Apps Script . To implement the API, use the special `doGet` trigger.
You should end up with something like this

function doGet(e){
  /* если `e` содержит параметр на отключение Формы */
  form.setAcceptingResponses(false);
  /* если `e` содержит параметр на разрешение Формы принимать ответы */
  form.setAcceptingResponses(true);
}

Publish the script as a web application and pull from python as much as you like. If you get too confused, you can publish it as an API and control access to the script at the user authorization level.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question