ユーザ用ツール

サイト用ツール


twitter_api:sample001

タイムライン取得

<?php
$username = 'clownwolc';
// 2012/10 Twitter API Changed
//$url = "http://twitter.com/statuses/user_timeline.xml?id=" . $username . "&count=20";
$url = "http://api.twitter.com/1/statuses/user_timeline.xml?id=" . $username . "&count=20";
$rss = simplexml_load_file($url);
echo "<img src=\"" . $rss->status->user->profile_image_url . "\">";
echo $rss->status->user->description;

foreach ($rss->status as $i) {
	$val = $i->text;
	$val = ereg_replace("(http)(://[[:alnum:]\S\$\+\?\.-=_%,:@!#~*/&]+)","<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",$val);
	$val = ereg_replace("(@)([[:alnum:]\S\$\+\?\.-=_%,:@!#~*/&]+)","<a href=\"http://twitter.com/\\2\" target=\"_blank\">\\1\\2</a>",$val);
	$val = ereg_replace("(>)(http://twitpic.com/)([[:alnum:]\S\$\+\?\.-=_%,:@!#~*/&]+)(</a>)","><img src=\"http://twitpic.com/show/mini/\\3\" /></a>",$val);
	echo "<p>" . $val . "<br />";
	echo "<a href=\"http://twitter.com/" . $i->user->screen_name . "/status/" . $i->id ."\">";
	echo date( "Y年m月d日H時i分", strtotime( $i->created_at ) );
	echo "</a>";
	echo  "</p>";
}
?>
twitter_api/sample001.txt · 最終更新: 2014/02/26 02:23 by clownclown

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki