1 Stella2 Stelle3 Stelle4 Stelle5 Stelle (Nessun voto ancora)
Loading ... Loading ...

[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';
}
?>

Ti piace questo articolo? Salvalo o condividilo!!
  • Twitter
  • Facebook
  • Digg
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • Live
  • Segnalo
  • StumbleUpon
  • Technorati
  • laaik.it
  • BarraPunto
  • email
  • Netvouz
  • BlinkList
  • Print
  • blogmarks
  • HelloTxt
  • FriendFeed
  • PDF

Post relativi

Leave a comment

Your comment