Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/11/2009, 12:20
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 22 años, 4 meses
Puntos: 834
Respuesta: Problema con API de Twitter y caracteres especiales

Probá así:
Código PHP:
<?php
    
function postToTwitter($username,$password,$message){
    
        
$host = "http://twitter.com/statuses/update.xml?status=".rawurlencode(htmlentities($message));
    
        
$ch = curl_init();
        
curl_setopt($ch, CURLOPT_URL, $host);
        
curl_setopt($ch, CURLOPT_VERBOSE, 1);
        
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
        
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        
curl_setopt($ch, CURLOPT_POST, 1);
        
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    
        
$result = curl_exec($ch);
        
$resultArray = curl_getinfo($ch);
        
curl_close($ch);
        if(
$resultArray['http_code'] == "200"){
            echo 
"<br />OK! postedo en http://twitter.com/".$username."/<br />";
        }else {
            echo 
"<br />Error! ha ocurrido un problema<br />";
        }
    }
    
postToTwitter("user","pass","Más pruebas");
?>