Created
January 9, 2015 05:07
-
-
Save hotta/5e742e0217c6d893da01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
if ($argc == 1) { | |
printf("Retrieve JSON data from specified URl and then decode.\n"); | |
printf("Usage: %s URL_that_returns_JSON\n", $argv[0]); | |
exit(0); | |
} | |
$a = file_get_contents($argv[1]); | |
$a = preg_replace('/^[\r\n\(]*/', '', $a); | |
$a = preg_replace('/\)$/', '', $a); | |
// var_dump($a); | |
if ($decoded = json_decode($a)) { | |
var_dump($decoded); | |
} else { | |
echo "error = ", json_last_error_msg(), "\n"; // require PHP >= 5.5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment