Script en php para enviar mensajes a una cuenta en twitter
Este script en php sirve para enviar a una cuenta en twitter mensajes.
La variable $mensaje la podriamos sacar de por ejemplo el ultimo titular de un articulo en nuestro blog o lo que queramos enviar.
140 caracteres de mierda es el limite.
$mensaje = "Hola mundo";
// los datos de la cuenta en twitter
$twitter_api_url = "http://twitter.com/statuses/update.xml";
$twitter_data = "status=$mensaje";
$twitter_user = "cuenta@twitter.com";
$twitter_password = "passwordtwitter";
// el tinglado
$ch = curl_init($twitter_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:{$twitter_password}");
$twitter_data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// si falla o no el envio y queremos por algun motivo mostrarlo
if ($httpcode != 200) {
echo "Algo ha fallado.";
}else{
echo "
“;
echo “Mensaje enviado “;
echo ““;
}
?>
En arcardes usamos algo asi.




















