Created
July 13, 2018 10:02
-
-
Save mnemocron/1df8a7e138845eda4b825935bb4826bc to your computer and use it in GitHub Desktop.
returns json from a json file.
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
<?php | |
header('Content-type: application/json'); | |
$filename = $_GET['f']; | |
$json_path = './resources/' . $filename; | |
if (file_exists($json_path) && strcmp(pathinfo($filename, PATHINFO_EXTENSION), 'json') ==0 ) { | |
$myfile = fopen($json_path, 'r') or die('Unable to open file!'); | |
$jsonstr = fread($myfile, filesize($json_path)); | |
fclose($myfile); | |
echo $jsonstr; | |
} else { | |
echo json_encode(array('status' => 'error')); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
api.foo.com/file2json.php?f=file.json