- Edited
Hi all, working on migrating my Database and its mostly going well! I think I found everything I need, but now I am trying to get things to talk to one another. Having an interesting issue that I feel is probably a very simple fix, I am just not sure how to find the answer (tried googling, I don't think I'm using the right terminology)
I am trying to just get a feel for how HTTPRequests work, so I set up a few php files of increasing complexity. Right now I'm stuck on the "Hello World" file lol. The problem isn't in the connection or the php files, its how the data is getting read on the Godot side. I have a very simple php file that is:
echo "Hellow World!
on the Godot side I've got:
@onready var http_request = $HTTPRequest
const SERVER_URL = "http://localhost/hello.php"
func _ready():
http_request.request_completed.connect(_http_request_completed)
send_request()
func send_request():
var headers = ["Content-Type: application/json"]
http_request.request(SERVER_URL, headers, HTTPClient.METHOD_GET)
func _http_request_completed(results, response_code, headers, body):
print(body)
var json = JSON.parse_string(body.get_string_from_utf8())
print(json)
Simple stuff. When I look at my log for the prints, the print(body) gives me an array of numbers (I am assuming each number is associated with a letter):
[72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
And when I print the json, I get <null>. So I am assuming the problem is in my headers, since that is determining what gets returned to me and its not returning a json object its just returning a string. But, I can't seem to find how this would be changed to make a string work. I tried changing it to "Content-Type: text/html; charset=UTF-8" but I am still getting the same info, a list of numbers. So I am not sure what the problem is.
I also tried putting the "Hello World" into a json format to see if that fixed things, since my code is looking for some json code, but that did not fix things. So I am just a little lost here at the moment at the basics. Any advice?