Using HttpService with Google Sheets


#21

Fair enough, but if you are even worrying about SQL injection.... then you might be 8 years behind modern web standards.[/quote]

While I agree with you that an SQL database is a much smoother and more flexible option..

This allows you to write JS (without node.js) instead of PHP/Java/C-Derivative. Which is great for this simple purpose of just simply moving data back and forth.
The major factor of why I'm considering this alternative is just purely the fact that it's free hosting. I don't have a purpose for a website outside of ROBLOX, and I don't see a point in paying ~5$ a month on top of BC costs.


#22

Question, how would one go about recording the chat history with this?


#23

[strike]Not sure where you got hsKey from what certain group of characters? I felt this part wasn't explained very well :emo-angst:[/strike]

Googled and found it if anyone found that a puzzle
https://productforums.google.com/forum/#!topic/docs/Vx0rggpH9nQ

Anyone interested, here is a chat log script
[spoiler]

local hs = game:GetService("HttpService")
local hsEntry1 = ""
local hsEntry2 = ""
local hsKey    = ""
local hsForm   = ""
local hsHost   = "https://docs.google.com/"
local function logSheet(var1, var2)
	local hsLink   = hsHost.."forms/d/"..hsForm.."/formResponse?entry."
	                 ..hsEntry1.."="..var1.."&submit=Submit&formkey="
	                 ..hsKey.."&entry."..hsEntry2.."="..var2.."&ifq"
	-- Upload onto Google Sheets!
	-- print(hsLink)
	hs:PostAsync(hsLink, "", 2)
end
function onChatted(msg, recipient, speaker)
	logSheet(speaker.Name, msg)
end
function onPlayerEntered(newPlayer)
	newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end
game.Players.ChildAdded:connect(onPlayerEntered)

[/spoiler]


#24

How would one go about updating a certain cell and not adding a new line?

Assuming we are maintaining a table, and the table consists of a name followed by a number, and is always ordered by name. When put into google sheets all of the current cells would just be replaced with the new values.

Hope you like my visualization


#25

Has anyone figured out if there is a way to read from spreadsheets using HttpService:GetAsync? I looked around some google APIs but I couldn't get anything going.


#26

Yeah, I'll be providing some details on that (unless someone wants to go ahead)

There is indeed a way to update cells, however I'm not exactly sure if it works in your case.


#27

Does Google Sheets have automatic data organization for things like average, max, min, current position in rankings (a function of row after ordering, I suppose), highest/lowest n number of values, and the keys for these values. (e.g. who are the top 10 players, where is suchandsuch in the leaderboard, what is the average score, etc.)


#28

Yeah, you would just need to create another spreadsheet and refer it off the spreadsheet that receives the values.

More details on the function stuff: https://support.google.com/docs/table/25273?hl=en


#29

I don’t know much about the internet or HTTP.

How would you format the hsLink string for three entries instead of two? Or four? I’m not sure what the pattern is. I’m trying to submit 13 entries.


#30

Using URL parameters? If I understand correctly, you would use a “?” for the first param and a “&” for everything after that.


#31

But why is there a
.."&submit=Submit&formkey=" ..hsKey..
between the two entries?

Can you give an example of what, say, four entries would look like?


#32

There is no particular order to how params can be specified. You can put more entries after the end of the string, in the middle, or in the beginning- it doesn’t matter. All the params get sent to the server at the same time, so as long as its present the server won’t care what order it’s in.

Now I’m not entirely sure about the format of Google Sheets, but you should be able to copy and paste the one from either entries and have no problem.


#33

Why don’t you do it directly? There’s a tutorial I did a while ago that’s a bit more complex but in the long run it’s perhaps a better option.


#34

Ah, I figured it out, thanks!

Because I’m very new to anything with HTTP and I just want to fill in some barebones example code and make a thing that works. Functionality!


#35

Been messing around with this code and the Google API.

I can’t seem to find a working way to perform a GetAsync request for the entries in the excel sheet. :confused:

Has anyone managed?


#36

What’s your code? I’d recommend snipping sensitive data


#37

It’s all good.

This beautiful person made a helpful tutorial :slight_smile:


#38

Sadly i think this method is outdated or else i did something wrong. If any of you know a similar method please let me know


#39

This still works. I managed to do it a few weeks ago. Chances are the URL is slightly incorrectly formatted. I had to play around for a few minutes for it to work.