Skip to content

Instantly share code, notes, and snippets.

@dugjason
Created September 17, 2012 10:50
Show Gist options
  • Save dugjason/3736667 to your computer and use it in GitHub Desktop.
Save dugjason/3736667 to your computer and use it in GitHub Desktop.
Reading a DataSift JSON file with PHP
<?php
$filename = dirname(__FILE__) . '/filename.json';
$filehandle = fopen($filename, 'r');
if ($filehandle) {
while (($interaction = fgets($filehandle, 4096)) !== false) {
$interaction = json_decode($interaction, true);
$total_processed++;
if (isset($interaction['twitter']['id'])) {
echo $interaction['twitter']['id'] . " - " . $interaction['interaction']['content'] . "\n";
}
}
fclose($filehandle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment