0 votes

I want to send some data to my website/webserver

In the Godot code i use the Template from the docs.

var dict = {'tscn': 'info'}

func _ready():
    _make_post_request('https://keys.quuli.ch/level.php', dict, true)

func _make_post_request(url, data_to_send, use_ssl):
    # Convert data to json string:
    var query = JSON.print(data_to_send)
    print(query)
    # Add 'Content-Type' header:
    var headers = ["Content-Type: application/json"]
    $HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)

func _on_HTTPRequest_request_completed(result, response_code, headers, body):
    var response = body.get_string_from_utf8()
        print(response)

and on my Webserver i just simply print the information that was given like this.

<?php 

print_r($_POST);

Now if i run the script i expect it to return the dict i made at the top but the array returned by PHP is empty ... do you have an idea why that is and how to fix it?

Godot version v3.4.2.stable.official [45eaa2daf]
in Engine by (14 points)

1 Answer

0 votes

If we can expect the template to be functional, and it is evoking a response from your server, I think it's fair to say it's probably a php issue. You didn't really supply enough php to get an idea of what's going on, so my guess is some configuration or handling of the data on the php side is the issue, not godot.

by (170 points)
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 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 webmaster@godotengine.org with your username.