Using an external website (dreamLo) to store high scores of players

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hayden
:warning: Old Version Published before Godot 3 was released.

I’m currently working on a simple test to try and use an external website to store information. The website is DreamLO and it basically uses links to add users to sites.
For example, in the basic example given in the site:
http://dreamlo.com/lb/UtF8xYVT00S9vI9hdyVFyAfxdpaVM_W0uWQhajd4zCNA/add/Carmine/100
That link would add a user called Carmine to the database with a score of 100. The names and scores can be swapped out and still work.
If you would like to click on the above link to see how it would work, I will let you all access the scoreboard (it is free to make a scoreboard and you can have an infinite amount) so that you can see how to above link can affect it.

So what I want to do is let the user open the add link without opening it in a browser. So I don’t want it to open with OS.Shell_Open ()
I’ve been trying to use the http request and http client, but I don’t think that is what I should be using.

I would greatly appreciate it if you could help, as I wanted to do a tutorial on using dreamlo with the godot engine instead of unity where it is commonly used, but it appears I’m the one who needs help.
Thanks in a advance!

EDIT: Apparently I have to use HTTP Request. I need some basic HTTP Request help.

BTW: this is the code I am using to attempt to open the website. I feel like it is incorrect.

const addUserURL = "http://dreamlo.com/lb/UtF8xYVT00S9vI9hdyVFyAfxdpaVM_W0uWQhajd4zCNA"
func _ready():
	testRequest ()
	pass

func testRequest ():
	var client = HTTPRequest.new()
	client.request (addUserURL + "/add/TEST/10")

Why wouldn’t the request method from the HTTPRequest node work?

bitbloom | 2017-11-17 05:51

I tried to use a http request, but i wasn’t sure what to do. I checked the documentation but I didnt really get it.
Do you know how I could, That would be helpful!

Hayden | 2017-11-17 06:57

Have you checked to see if your firewall is allowing the request to be sent? I’ll try to have a play with this when I get some free time. A leaderboard is definitely something I’ll be doing as well when my game is near completion. I plan on rolling my own but it looks similar to how I plan on doing it on the client side.

Michael Paul | 2017-11-17 07:16

I allow my firewall to use Godot engine. I think. How would I go about changing the firewalls?

Hayden | 2017-11-17 08:26

It depends on your OS and if your AV has it’s own firewall as well.
In Windows, you can open the Windows Firewall app from Control Panel and click Advanced Setting. There you can see Inbound and Outbound rules. Godot is probably already set to allow incoming, but maybe not outgoing (in my case anyway). Rather than muck around with the rules, I’d just turn the firewall off temporarily and give your code a go. If it works with the firewall off, then that’s likely the problem and you can figure out how to handle the rules at that point. BTW, I’m just throwing out possibilities, which could be completely off track since I haven’t tried it yet.

Michael Paul | 2017-11-17 08:56

:bust_in_silhouette: Reply From: MrMonk

with my noob skills I quickly tried this and worked. Any way good find.

extends Node

func _ready():
	getRequest()
	pass

func getRequest():
	var err=0
	var http = HTTPClient.new() # Create the Client

	var err=http.connect("http://dreamlo.com",80)
	assert(err==OK) # Make sure connection was OK

# 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)

assert( http.get_status() == HTTPClient.STATUS_CONNECTED ) # Could not connect
	
# Some headers
var headers=["User-Agent: Pirulo/1.0 (Godot)","Accept: */*"]


var url="/lb/UtF8xYVT00S9vI9hdyVFyAfxdpaVM_W0uWQhajd4zCNA/add/MrMonk/10"

err = http.request(HTTPClient.METHOD_GET, url, headers)


assert( err == OK ) # Make sure all is OK

Thank you so much! So helpful!

Hayden | 2017-11-25 09:09

It’s a bit late but maybe it’l still be possible to get an answer to a followup question:

The above code works perfectly fine for my testing. But how would I be able to pull the high scores back into godot to display it?

toshbar | 2019-01-18 01:58