Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Mentuhetep |
Hi, I am trying to implement something similar to this but in Godot.
It just sends player responses to a google form.
https://www.youtube.com/watch?v=z9b5aRfrz7M
https://github.com/luzan/Unity-Google-Spreadsheet/blob/master/Assets/SendToGoogle.cs
I’ve managed to connect with the web site and make the request. But for some reason it is not submiting the respose.
This is what I’ve got so far:
func _send_data():
var err = 0
var http = HTTPClient.new() # Create the Client.
err = http.connect_to_host("docs.google.com", 80) # Connect to host/port.
assert(err == OK) # Make sure connection was OK.
print (err)
# Wait until resolved and connected.
while http.get_status() == HTTPClient.STATUS_CONNECTING or http.get_status() == HTTPClient.STATUS_RESOLVING:
http.poll()
print("Connecting...")
OS.delay_msec(500)
print (http.get_status())
assert(http.get_status() == HTTPClient.STATUS_CONNECTED) # Could not connect
var header = ["entry.986078935", "Content-Type: application/json"]
var field = JSON.print(str(user_melody))
var result = http.request(http.METHOD_POST, "/forms/d/e/1FAIpQLSe8Z91NGAN-ssDJbMSOuZtM7eWZQvt8mWoMxuJ79HtM-f4Qkg/formResponse", header, field)
print(result)
# Keep polling until the request is going on
while (http.get_status() == HTTPClient.STATUS_REQUESTING):
http.poll()
print("Requesting...")
OS.delay_msec(300)
# Make sure request finished
print (http.get_status())
assert(http.get_status() == HTTPClient.STATUS_BODY or http.get_status() == HTTPClient.STATUS_CONNECTED)
The debug Output prints:
0
Connecting...
Connecting...
5
0
Requesting...
Requesting...
7
Not sure what is going on… If you have any clue, please let me know!
I want to do the same thing but with sheets will it work directly or I need to use google forms first, as you did?
Help me please | 2021-07-19 12:13