Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | pengyou |
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())
print(json.result)
print(result)
print(response_code)
print(body.get_string_from_ascii())
my php codes:
public function actiontest()
{
$value = array(
'value'=>$_POST
);
if(isset($_POST) && $_POST!=null)
{
echo json_encode($value);
}else
{
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?