This commit is contained in:
Kai Hendry
2014-12-06 21:22:12 +08:00
parent cd1265d3d7
commit 18cdf60aae
26 changed files with 5 additions and 7 deletions

28
www/json-to-text.php Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php
$json_string = file_get_contents("php://stdin");
$foo = json_decode($json_string);
for ($i=0; $i<count($foo); $i++){
echo $foo[$i]->id_str . "|";
echo $foo[$i]->created_at . "|";
$tweet = str_replace("\n", " ", $foo[$i]->text);
if (!empty($foo[$i]->entities->urls)) {
foreach($foo[$i]->entities->urls as $u) {
//print_r($u->url);
////print_r($u->expanded_url);
$tweet = str_replace($u->url,$u->expanded_url,$tweet);
}
}
if (!empty($foo[$i]->entities->media)) {
foreach($foo[$i]->entities->media as $m) {
//print_r($u->url);
////print_r($u->expanded_url);
$tweet = str_replace($m->url,$m->media_url,$tweet);
}
}
echo $tweet . "\n";
}
//print_r($foo);
//$pp = json_encode($foo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
//echo $pp;
?>