<?php $sUrl = 'http://125.209.77.54:8181/locationVeh/LED:18:4089/KrvpjgKAQyTJlfz05Urijw=='; $params = array('http' => array('method' => 'POST')); $ctx = stream_context_create($params); $response = file_get_contents($sUrl, false, $ctx); $data = json_decode($response, true); echo $response; echo $data['lat']; echo $data['lng']; ?>
I tested on the localhost it works fine which shows 29.88288 and 71.7381 while on the host server shows empty. I tried to use allow_url_open
to 1.
Advertisement
Answer
On Host server fopen is disabled that’s why file_get_contents() function is not working on server . You can use the Curl to get the data .
To check the fopen create the phpinfo(); in test PHP and run test.php file
Thanks