Get the data from json url using php? -
this json api : https://jobs.github.com/positions.json?description=java&page=1 want data url.
<?php $url = file_get_contents('https://jobs.github.com/positions.json?description=java&page=1'); var_dump(json_decode($url,true)); ?>
this code return null check url in json validator: http://jsonformatter.curiousconcept.com/ json valid con't able data url please me...
try script determine problem is. if there no json module installed (see @julian comment), can try use php implementations of json this: http://pear.php.net/pepr/pepr-proposal-show.php?id=198
if (! extension_loaded('json')) { echo 'module json not available!'; exit(); } $url = file_get_contents('https://jobs.github.com/positions.json?description=java&page=1'); $data = json_decode($url,true); switch (json_last_error()) { case json_error_none: echo ' - no errors'; break; case json_error_depth: echo ' - maximum stack depth exceeded'; break; case json_error_state_mismatch: echo ' - underflow or modes mismatch'; break; case json_error_ctrl_char: echo ' - unexpected control character found'; break; case json_error_syntax: echo ' - syntax error, malformed json'; break; case json_error_utf8: echo ' - malformed utf-8 characters, possibly incorrectly encoded'; break; default: echo ' - unknown error'; break; }
Comments
Post a Comment