Mostrar últimos Tweets con PHP
Con este simple script PHP podemos mostrar los últimos tweets de un usuario. Sólo debemos pasarle como parámetro el nombre de usuario de la cuenta y el número de tweets a mostrar.
function my_twitter($usuario,$tweets) {
$feed = «http://search.twitter.com/search.atom?q=from:» . $usuario . «&rpp=» . $tweets;
$xml = simplexml_load_file($feed);
foreach($xml->children() as $child) {
foreach ($child as $value) {
if($value->getName() == «content») {
$content = $value . «»;
echo ‘
$feed = «http://search.twitter.com/search.atom?q=from:» . $usuario . «&rpp=» . $tweets;
$xml = simplexml_load_file($feed);
foreach($xml->children() as $child) {
foreach ($child as $value) {
if($value->getName() == «content») {
$content = $value . «»;
echo ‘
’.$content.’
’;
}
}
}
}
Luego para mostrar los tweets solo basta con:
my_twitter(«sessionstudio»,5);
Visto en webintenta
