$cache_dir,'caching' => true,'lifeTime' => $cache_period, 'automaticCleaningFactor' => $auto);
$Cache_Lite = new Cache_Lite($options);
$cache = $Cache_Lite->get($cache_id);
/**
* データー取得コード
**/
/* ここから */
if($cache){ $xml = $cache;} else {
$xml = implode ( "", file ( "http://twitter.com/statuses/user_timeline/" .$screenName. ".xml" ) );
// $xml = file_get_contents('http://twitter.com/statuses/user_timeline/" .$screenName. ".xml');
if ($xml) {
$Cache_Lite->save($xml, $cache_id );
}
}
$opt = array (
'complexType' => 'object',
'parseAttributes' => 'true',
'attribuesArray' => '_attributes',
'targetEncoding' => 'utf-8');
$Unserializer =& new XML_Unserializer($opt);
$status = $Unserializer->unserialize($xml);
if (PEAR::isError($status)) {
// die($status->getMessage());
}
$lines_o = $Unserializer->getUnserializedData();
$lines = $lines_o->status;
/* ここまで */
/**
* PHP 5.0以上用データー取得コード 上記コードを簡単に記述できます。ご参考に。
* このコードを利用する際は、上記「データー取得コード」を消去し、require_once ('Unserializer.php');をコメントアウトしてください。
**/
/* ここから */
//if($cache){ $xml = $cache;} else {
// $xml = file_get_contents('http://twitter.com/statuses/user_timeline/" .$screenName. ".json');
// if ($xml) {
// $Cache_Lite->save($xml, $cache_id );
// }
//}
//$lines = json_decode($xml);
/* ここまで */
/**
* コンテンツ表示
**/
//var_dump($lines);
$n = 0;
foreach ($lines as $line) {
$stamp = '';
$deltaTime = time()-$jisa-strtotime(str_replace(' +0000', '', $line->created_at));
if ($deltaTime < 60*60) {
$stamp = floor($deltaTime/60).'minite';
if (floor($deltaTime/60) > 1) {$stamp.= 's';}
$stamp.= ' ago';
} elseif ($deltaTime < 60*60*24) {
$stamp = floor($deltaTime/(60*60)).'hour';
if(floor($deltaTime/(60*60)) > 1) {$stamp.= 's';}
$stamp.= ' ago';
} elseif ($deltaTime < 60*60*24*30) {
$stamp = floor($deltaTime/(60*60*24)).'day';
if(floor($deltaTime/(60*60*24)) > 1) {$stamp.= 's';}
$stamp.= ' ago';
} elseif ($deltaTime < 60*60*24*365) {
$stamp = floor($deltaTime/(60*60*24*30)).'month';
if(floor($deltaTime/(60*60*24*30)) > 1) {$stamp.= 's';}
$stamp.= ' ago';
} else {
$stamp = floor($deltaTime/(60*60*24*365)).'year';
if(floor($deltaTime/(60*60*24*365)) > 1) {$stamp.= 's';}
$stamp.= ' ago';
}
$stamp = '' . $stamp . '';
echo mb_convert_encoding($line->text . ' ' . $stamp, $charset,'utf-8' )."
";
$n++;
if($n>=$contentsNum) {break;}
}
?>