[tutorial-php] Eseguire un post su Twitter.com da PHP
Se state facendo un applicazione in php e volete intergrare Twitter.com ho trovato questo script che permette di collegarsi al sito ed eseguire un post. Ovviamente sostituite ‘username‘ e ‘password‘ con le vostre credenziali.
// Set username and password
$username = 'username';
$password = 'password';
// The message you want to send
$message = 'is twittering from php using curl';
// The twitter API address
$url = 'http://twitter.com/statuses/update.xml';
// Alternative JSON version
// $url = 'http://twitter.com/statuses/update.json';
// Set up and execute the curl process
$curl<em>handle = curl</em>init();
curl<em>setopt($curl</em>handle, CURLOPT<em>URL, "$url");
curl</em>setopt($curl<em>handle, CURLOPT</em>CONNECTTIMEOUT, 2);
curl<em>setopt($curl</em>handle, CURLOPT<em>RETURNTRANSFER, 1);
curl</em>setopt($curl<em>handle, CURLOPT</em>POST, 1);
curl<em>setopt($curl</em>handle, CURLOPT<em>POSTFIELDS, "status=$message");
curl</em>setopt($curl<em>handle, CURLOPT</em>USERPWD, "$username:$password");
$buffer = curl<em>exec($curl</em>handle);
curl<em>close($curl</em>handle);
// check for success or failure
if (empty($buffer)) {
echo 'message';
} else {
echo 'success';
}
?>
Post relativi
luglio 16, 2008 in
Filosofia, Intrattenimento, My Brain, Opensource, Programmi, Scriptare, Tutorials, Twitter, Web 2.0, White side of Brain | tags: applicazioni web2.0, php, post, programmazione, tutorial, Twitter, twitter.com, Vi, Web 2.0

