jul
22
2010
22
2010
Subir una imagen a TwitPic con cURL y PHP
Sube tus imágenes e TwitPic con php y Curl
<? $file = $_FILES['media']; if (!in_array($file['type'], array('image/png','image/jpeg','image/gif'))) { echo '<span style="color:#CC0000;">Not a valid file type, please upload PNG, JPEG or GIF images only.</span>'; exit; } $postfields = array(); $postfields['username'] = $username; $postfields['password'] = $password; $postfields['media'] = "@$file['tmp_name']"; $twitter_url = 'http://twitpic.com/api/upload'; $curl = curl_init(); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1); curl_setopt($curl, CURLOPT_URL, $twitter_url); curl_setopt($curl, CURLOPT_POST, 3); curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields); $result = curl_exec($curl); curl_close($curl); $login_xml = new SimpleXMLElement($result); if (isset($login_xml->error)) { print_r($login_xml); } else { print_r($login_xml); } ?>
Related Posts
Leave a comment
Patrocinador
Siguenos
Suscribete
Correo @zoneartcss.com
Comentarios
- juan manuel en Subdominios con php y .htaccess
- PCHART-Crear gráficas en PHP | Espacio de *M@?!*[lOs KeRoS mUcHo a ToDoS...] en Pchart – Crear gráficas en PHP
- EH en Evitar resize de un textarea con CSS
- KAREN en Envia mensajes de texto gratis a celulares telcel
- Elie Cottage en Ventajas y desventajas de tener un blog gratis

An article by






