Search code examples
phpgetport

how to get JSON data from unusual port in php?


i have scout_realtime, and i want to get stats.json from it. in debug it looks like

91.205.168.39 - - [10/Nov/2018:09:54:22 CET] "GET /stats.json HTTP/1.1" 200 3896
http://188.165.3.*:5556/ -> /stats.json

how to get it manially? I tried to do something like this:

$status = file_get_contents('http://188.165.3.*:5556/stats.gson')

but it doesnt work


Solution

  • $url = 'http://188.165.3.*:5556/stats.json';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    

    ok i made it myself :D