Google Forms New Format
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Google Forms New Format
Thanks to several people here I have been able to record student scores via google forms (post myData to url....). However, soon Google is migrating all forms/spreadsheets to a new format (see: https://support.google.com/drive/answer ... grate&rd=1), and I have not had success in getting form data to post into these new spreadsheets. I am really hoping they are not closing the door on the ability to post data.
The old url (prior to the key) for forms looks like so:
https://spreadsheets.google.com/formResponse?formkey=
But the new ones are very different:
https://docs.google.com/forms/d/
Has anyone had success with this?
The old url (prior to the key) for forms looks like so:
https://spreadsheets.google.com/formResponse?formkey=
But the new ones are very different:
https://docs.google.com/forms/d/
Has anyone had success with this?
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Google Forms New Format
Just bringing this thread back to the top. Google has indeed deprecated the old format. I'd be grateful if anyone has figured out a way to submit data into google spreadsheets with the forms' new key format.
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Google Forms New Format
Update:
Looks like google no longer allows form data to be sent in one long url. If anyone knows how to create "post" data I would appreciate any insight. Here is what I found:
"Please excuse any part of this explanation that might come off as too simple. Wanted to point out a couple things in case you weren't aware.
The actual data I need to post is:
StudentName
StudentInstrument
StudentMinutes (how long they played the game)
StudentLevel
StudentScore
StudentPercentage
tCourse
tTeacher
Thank you for any help.
Looks like google no longer allows form data to be sent in one long url. If anyone knows how to create "post" data I would appreciate any insight. Here is what I found:
"Please excuse any part of this explanation that might come off as too simple. Wanted to point out a couple things in case you weren't aware.
And here is an example of the POST format, but I don't know if I can replicate this with LiveCode?When you build a URL with query variables that looks like this example.com?key=value&otherkey=othervalue you are using what web developers refer to as GET syntax. It is generally believed to be insecure (as the entire URL, and thus all the data you sent, shows up in the server logs and is easy to intercept).
Because of this, Google has shifted to a method that is more frequently used known as POST. When you use GET on a web form (like the old Google form) it creates a URL with all the keys and values and then hits that URL and a script file decodes it right from the URL.
When you do the same with a POST form, the URL in the "action" attribute of the form tag is called as-is and the data is POSTED to the server behind the scenes.
Here's a copy of my form for your reference. I've omitted all of the Javascript submission stuff, as the part of the form you're most interested in doesn't use it."
Code: Select all
<form action="https://docs.google.com/forms/d/16TltcvKi2nph-wora13uedVGJ5k6rr4MwTeLh1lfmkc/formResponse" method="POST" id="ss-form">
<h1>Inventory Tagging
<br>San Diego</h1>
<p>
<label class="ss-q-title" for="entry_1">Site Number</label>
<input type="text" name="entry.1" value="" class="ss-q-short" id="entry_1" maxlength="9">
</p>
<p>
<label class="ss-q-title" for="entry_2">Bin</label>
<input type="text" name="entry.2" value="" class="ss-q-short" id="entry_2" maxlength="6">
</p>
<p id="message">Updated</p>
<p>
<input type="submit" name="submit" value="Submit" id="submit">
</p>
</form>
StudentName
StudentInstrument
StudentMinutes (how long they played the game)
StudentLevel
StudentScore
StudentPercentage
tCourse
tTeacher
Thank you for any help.
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Google Forms New Format
Made some progress. I used "get" to retrieve the data from my google form and found that they have changed the way they refer to each entry. Formerly you would set up the post like so:
And now it's like:
Then you assign your values, such as:
You need the ampersand so the values will all be strung together for the post.
Once you've done that you can build the post:
To set up the post, this is the new format:
And then finally
Code: Select all
put "entry.0.single" into tFieldName1
put "entry.1.single" into tFieldName2
put "entry.2.single" into tFieldName3
put "entry.3.single" into tFieldName4
Code: Select all
put "entry.1000000=" into tFieldName1
put "entry.1000001=" into tFieldName2
put "entry.1000002=" into tFieldName3
put "entry.1000003=" into tFieldName4
Code: Select all
put studentName into tFieldValue1
put "&" after tFieldValue1
Once you've done that you can build the post:
Code: Select all
put tFieldName1&tFieldValue1&tFieldName2&tFieldValue2&tFieldName3&tFieldValue3&tFieldName4&tFieldValue4 into myList
Code: Select all
put "https://docs.google.com/forms/d/YOURGOOGLEKEYHERE/formResponse" into tformKey
Code: Select all
post myList to URL tformKey
Re: Google Forms New Format
This reply is a bit late, but would you be willing to share example code of using the GET command to retrieve data from Google Sheets? I used your code to save data, and it works like a charm, but can't quite figure out how to read from the spreadsheet.
Thanks,
Mark
Thanks,
Mark
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Google Forms New Format
Hi Mark, I'm really sorry for only seeing this now. Here is how I pull the info from a google spreadsheet. Of course, the spreadsheet privacy must be set to "anyone with the link"
As you probably know, all google docs have an identifying "key" that can be found in the url. So:
This will give you a json result that you can parse. I included the statements for sorting just so you could see what that looks like. The %20 are all in place of spaces.
See also: https://coderwall.com/p/pluhsg/google-s ... -filtering
As you probably know, all google docs have an identifying "key" that can be found in the url. So:
Code: Select all
put <yourKeyHere> into tPrefsKey
put "https://spreadsheets.google.com/a/google.com/tq?tqx=out:json&tq=select%20A,B,C,D%20order%20by%20A%20desc&key=" into tFirstPart
put tFirstPart&tPrefsKey into wholeURL
libURLSetSSLVerification false
get url wholeURL
put it into preGArray
See also: https://coderwall.com/p/pluhsg/google-s ... -filtering
Re: Google Forms New Format
And thanks for the response. It appears that we teachers don't check here often enough!
- Mark
- Mark
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Google Forms New Format
Hi @teacherguy & @acidjazz, despite the fact that is an old post I decided to give it a try instead of starting a new one about the some subject.
I've followed the guidelines with no luck.
My "Post" code is:
and even though I get no error and a new entry is created in the spreadsheet it has no answer as can be seen on the picture below (I guess I'm doing something wrong with the fieldName):
On the other hand when I try to "Get" the contents of the spreadsheet with the following code
I get the error in the attached picture.
Any hint or suggestion would be very much appreciated. What I'm trying to achieve is a very simple App that would log the mobile GPS location to the spreadsheet.
Many thanks!
I've followed the guidelines with no luck.
My "Post" code is:
Code: Select all
on mouseUp
put "-----------------------" into myKey
put "entry.Question1=" into tFieldName1
put "Answer2" into tFieldValue1
put "&" after tFieldValue1
put tFieldName1&tFieldValue1 into myList
put "https://docs.google.com/forms/d/" into tformKey
put myKey & "/formResponse" after tformKey
answer tformKey
post myList to URL tformKey
answer the result
end mouseUp
On the other hand when I try to "Get" the contents of the spreadsheet with the following code
Code: Select all
on mouseUp
put "--------------------------" into tPrefsKey
put "https://spreadsheets.google.com/a/google.com/tq?tqx=out:json&tq=select%20A,B,C,D%20order%20by%20A%20desc&key=" into tFirstPart
put tFirstPart&tPrefsKey into wholeURL
libURLSetSSLVerification false
get url wholeURL
answer it
end mouseUp
Any hint or suggestion would be very much appreciated. What I'm trying to achieve is a very simple App that would log the mobile GPS location to the spreadsheet.
Many thanks!
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Google Forms New Format
It seems that Google changes how it works so often that it's almost not worth trying to keep up with it. I've almost completely abandoned LiveCode because the html5 functionality is just not where it needs to be (nor does it look like it ever will be), and have just had to teach myself javascript. Very frustrating, but not much we can do, I guess.
Mark
Mark
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Google Forms New Format
I'm not clear: if the problem with LiveCode or with Google's API changes? Was your script working well before Google changed?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Google Forms New Format
Richard,
To be fair, I haven't tried this script for years now, so I can't really speak to it directly. My comments were directed at a few different frustrations and I did it in an unclear fashion. Let me restate. I have abaondoned LiveCode mostly because I run experiments online, and the html version just doesn't do what I need, at least not without having to interject javascript a lot. So, I finally just bit the bullet and am doing everything via javascript. I love livecode, and if I were only using it in the lab (offline) I'd be happy.
As for the Google API, I also haven't tried it in a while, because I got frustrated with that too, because it's a pain. So, I use my own server, and write in HTML, javascript, and CSS and save simple textfiles. I just might not be smart enough to do more.
- Mark
To be fair, I haven't tried this script for years now, so I can't really speak to it directly. My comments were directed at a few different frustrations and I did it in an unclear fashion. Let me restate. I have abaondoned LiveCode mostly because I run experiments online, and the html version just doesn't do what I need, at least not without having to interject javascript a lot. So, I finally just bit the bullet and am doing everything via javascript. I love livecode, and if I were only using it in the lab (offline) I'd be happy.
As for the Google API, I also haven't tried it in a while, because I got frustrated with that too, because it's a pain. So, I use my own server, and write in HTML, javascript, and CSS and save simple textfiles. I just might not be smart enough to do more.
- Mark
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Google Forms New Format
Just an update on my previous post.
I was able to get the Post to work properly, it was in fact a problem with the fieldName I was using. This is how I solved it:
1 - Open the Form source code
2 - Search for the text of question (Question1 in my case)
3 - Just after the second occurrence (see below) you can find name="entry.1775847828"
5 - Bingo!!!
I still would like to have the GET part working...
Best
I was able to get the Post to work properly, it was in fact a problem with the fieldName I was using. This is how I solved it:
1 - Open the Form source code
2 - Search for the text of question (Question1 in my case)
3 - Just after the second occurrence (see below) you can find name="entry.1775847828"
4 - Usearia-label="Question1" aria-describedby="i.desc.170916459 i.err.170916459" name="entry.1775847828" value="" dir="auto" data-initial-dir=
Code: Select all
put "entry.1775847828=" into tFieldName1
I still would like to have the GET part working...
Best
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
-
- Posts: 379
- Joined: Thu Dec 08, 2011 2:43 am
Re: Google Forms New Format
Simon my apologies for not seeing this until now. Have you been able to use "GET" at this point? I am still able to use it and I can dig into my code and see what changes I had to make.
-
- Posts: 641
- Joined: Tue Jul 29, 2014 12:52 am
- Location: Brazil
Re: Google Forms New Format
Hi @teacherguy, no worries I got it working...all good
thanks for getting back to me
Cheers
thanks for getting back to me
Cheers
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question