Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/12/2011, 18:27
maczy
 
Fecha de Ingreso: noviembre-2011
Mensajes: 69
Antigüedad: 12 años, 5 meses
Puntos: 0
obtener Captcha CURL

hola a todos estoy intentando hacer mi web para envio de sms, y estoy estudiando el metodo CURL para obtener la imagen de verificacion aunque creo que despues tendria que enviar toda esa informacion a sus campos correspondientes, otra problema.
Consegui este codigo PHP curl, logre hacer que me traiga solo el codigo pero estatico, es decir la unica que hice es colocar la direccion de la imagen dejo una muestra del codigo:

Código PHP:
<?php

// standard browser header
$user_agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7";
$ref 'http://sms.personal.com.ar/Mensajes/msn.htm';
$file './cookie.txt';
// the target url which contains scripts that generates the cookie
$url "http://sms.personal.com.ar/Mensajes/msn.htm";

$ch curl_init();

// set user agent
curl_setopt($chCURLOPT_USERAGENT$useragent);
// set the target url
curl_setopt($chCURLOPT_URL,$url);
curl_setopt($chCURLOPT_COOKIEJAR$file);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
// execute curl,fetch the result and close curl connection
$resultcurl_exec ($ch);
// close the connection
curl_close($ch);




// Allocate a new cURL handle that gets the captcha image



$ch curl_init("http://sms3.personal.com.ar/Mensajes/tmp/6048fr731jsajtig.png");
if (! 
$ch) {
   die( 
"Cannot allocate a new PHP-CURL handle" );
}

// We'll be returning this transfer, and the data is binary
// so we don't want to NULL terminate
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_BINARYTRANSFER1);
curl_setopt($chCURLOPT_COOKIEFILE$file); 
// Grab the jpg and save the contents in the $data variable
$data curl_exec($ch);
// close the connection
curl_close($ch);
// Set the header to type image/jpeg, since that's what we're
// displaying
header("Content-type: image/jpeg");
// Output the image
print( $data );
?>