Skip to content

Instantly share code, notes, and snippets.

@jensvaaben
Created October 19, 2014 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensvaaben/633077869a27c3193343 to your computer and use it in GitHub Desktop.
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.
<?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