php - Issue trying to print data from a web service with function file_get_contents -
when use code print data local json file works perfect.
$json_string = 'data.json'; $jsondata = file_get_contents($json_string); $obj = json_decode($jsondata,true); echo "<pre>"; print_r($obj);
but can´t make works web service. don't results..
$json_string = 'http://ddddd.com/ws/ws_get_news.php?limit=10'; $jsondata = file_get_contents($json_string); $obj = json_decode($jsondata,true); echo "<pre>"; print_r($obj);
what i'm doing wrong?
thanks.
it looks first characters of generated json problem. possible generating utf8-bom? can solve strip first characters. try this:
$json_string = 'http://dattabasic.com.ar/~masterli/admin/ws/ws_get_categorias.php'; $jsondata = file_get_contents($json_string); $jsondata = substr($jsondata,3); $obj = json_decode($jsondata,true); echo "<pre>"; print_r($obj); echo "</pre>";
Comments
Post a Comment