Fonction PHP pour envoyer un Twit
function twitter_message($login, $mot_de_passe, $message)
{
$url = 'http://twitter.com/statuses/update.xml';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "$url");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$message");
curl_setopt($curl_handle, CURLOPT_USERPWD, "$login:$mot_de_passe");
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
if (empty($buffer))
return 0;
else
return 1;
}
Utilisation:
twitter_message ("login","mot de passe", "votre message"); //qui peut être trouver dans un formulaire en POST
Plus d’info sur CURL ICI
Les Commentaires