0 votes

I have been follow godot documentation to send data to my server. The connection is okay, but the data sent to my php web is always null. Anyone please guides me on this.

my godot codes:

func _make_post_request(url, data_to_send, use_ssl):
   var query = JSON.print(data_to_send)
   var headers = ["Content-Type: application/json"]
   $HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)

func _on_Button_pressed():
    _make_post_request("http://localhost/buymall/site/test","Hello World",false)

func _on_HTTPRequest_request_completed(result, response_code, headers, body):
    var json = JSON.parse(body.get_string_from_utf8())

my php codes:

public function actiontest()
    $value = array(
    if(isset($_POST) && $_POST!=null)
        echo json_encode($value);
        echo "no post value";

The outcome when i press POST button is always return "no post value" from my php site. What are the things i did wrong?

asked Mar 28 in Engine by pengyou (42 points)
edited Mar 28 by pengyou

Please log in or register to answer this question.

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.