Tema: PHP Tweets
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/11/2010, 14:13
acidlake
 
Fecha de Ingreso: noviembre-2010
Ubicación: /home/RD/Villa_Altagracia
Mensajes: 18
Antigüedad: 13 años, 5 meses
Puntos: 4
Respuesta: PHP Tweets

aver si entendi, deseas publicar tweets desde php??
weno aca te doy un ejemplo, le haces las modificaciones, para automatizarlo, usarlo con una DB etc etc.

Código PHP:
Ver original
  1. $username = 'myUserName';
  2. $password = 'myPassword';
  3. $status = urlencode(stripslashes(urldecode('This is a new Tweet!')));
  4.  
  5. if ($status) {
  6. $tweetUrl = 'http://www.twitter.com/statuses/update.xml';
  7.  
  8. $curl = curl_init();
  9. curl_setopt($curl, CURLOPT_URL, "$tweetUrl");
  10. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
  11. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  12. curl_setopt($curl, CURLOPT_POST, 1);
  13. curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
  14. curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
  15.  
  16. $result = curl_exec($curl);
  17. $resultArray = curl_getinfo($curl);
  18.  
  19. if ($resultArray['http_code'] == 200)
  20. echo 'Tweet Posted';
  21. else
  22. echo 'Could not post Tweet to Twitter right now. Try again later.';
  23.  
  24. curl_close($curl);
  25. }