Created
October 19, 2014 18:04
-
-
Save jensvaaben/633077869a27c3193343 to your computer and use it in GitHub Desktop.
This is a small sample file that will consume output produced by https://dvbseserviceproc.codeplex.com. This is just to get you started, i.e. it will only validate a few of the expected properties.
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 | |
$fp = fopen("php://input","r"); | |
$data = stream_get_contents($fp); | |
$decode = json_decode($data); | |
if($decode == null) { | |
header("HTTP/1.0 500 Internal Server Error"); | |
header("Content-Type: text/plain"); | |
echo "failed to decode JSON\n"; | |
exit; | |
} | |
else { | |
foreach($decode as $value) { | |
// check a few properties, but not all possible properties. | |
if(!property_exists($value,"name")) { | |
header("HTTP/1.0 500 Internal Server Error"); | |
header("Content-Type: text/plain"); | |
echo "property name not found\n"; | |
exit; | |
} | |
if(!property_exists($value,"provider")) { | |
header("HTTP/1.0 500 Internal Server Error"); | |
header("Content-Type: text/plain"); | |
echo "property provider not found\n"; | |
exit; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment