11
08月
2015
28. 从任意的 Twitter 账号获取最新的 Tweet
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function my_twitter($username)
{
$no_of_tweets = 1;
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $no_of_tweets;
$xml = simplexml_load_file($feed);
foreach($xml->children() as $child) {
foreach ($child as $value) {
if($value->getName() == "link") $link = $value['href'];
if($value->getName() == "content") {
$content = $value . "";
echo '<p class="twit">'.$content.' <a class="twt" href="'.$link.'" title=""> </a></p>';
}
}
}
}
|
语法:
|
1
2
3
4
|
<?php
$handle = "koonktech";
my_twitter($handle);
?>
|
特殊说明,本文版权归 ning个人博客 所有带原创标签请勿转载,转载请注明出处.