+2 votes

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:
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 ()

func testRequest ():
    var client = HTTPRequest.new()
    client.request (addUserURL + "/add/TEST/10")
in Engine by (17 points)
edited by

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

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!

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.

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

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.

1 Answer

+2 votes
Best answer

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

extends Node

func _ready():

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

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
by (530 points)
selected by

Thank you so much! So helpful!

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.