Thanks!smh use cURL. The content contained " " which you didn't strip with strip_tags
Code:$ch = curl_init('https://api.mcuuid.com/json/server/test.blaa.net:25589'); curl_setopt_array($ch, array( CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_RETURNTRANSFER => 1 )); $res = curl_exec($ch); if (!$res) { die('Could not connect.'); } var_dump(json_decode(strip_tags(str_replace(' ', '', $res))));
Incrementing
Please don't output your JSON with html tags & nbsp's...
Code:$data = array( 'key' => 'value' ); header('Content-Type: application/json'); echo json_encode($data, JSON_PRETTY_PRINT);
More Suggestions:
- Use "ServerTokens Prod" to avoid showing your server version
- Use nginx, it's so much better than apache
- (personal preference: centos over ubuntu
)
- Invalid API endpoints should return a JSON response, not a 404 document
Btw: You forgot the " ,true " in the json_decode.
