I have a geolocation PHP program sitting at:
https://url.com/geo?ip=8.8.8.8
It fetches a response from another server using file_get_contents
. The response from the other server is a valid JSON string. The above program then echo
s the JSON response.
The problem is that the response, or rather the echo
is HTML output instead of JSON. This pollutes our nameserver analytics, as every request to the geo API is now recorded as HTML. Other problems arise from applications using my API, because they expect strict JSON output.
How can I print the JSON response as a JSON response?