Scripts para interactuar con Twitter
14-09-2009 Programación 4354 hits (38.15 %) 3 comentarios
Como Twitter está de moda CatsWhoCode nos presenta 10 fragmentos de códigos, en diversos lenguajes de programación, para interactuar con este servicio.
Por ejemplo está este código en PHP que obtiene el número de seguidores.
<?php
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name=catswhocode');
if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
echo $tw['count'];
?>
Ó puedes probar esta otra para obtener la actividad reciente en tu cuenta de Twitter:
<?php
function get_status($twitter_id, $hyperlinks = true) {
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
preg_match('/<text>(.*)<\/text>/', $src, $m);
$status = htmlentities($m[1]);
if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=http://feedproxy.google.com/%22//0/%22>//0</a>%22, $status);
return($status);
}
?>
Nosotros mencionamos anteriormente un código en PHP para enviar mensajes aTwitter.

Sunplace Solutions® - Soluciones Informáticas
Buen articulo.