Ver Mensaje Individual
  #5 (permalink)  
Antiguo 29/10/2009, 17:35
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 1 mes
Puntos: 20
Respuesta: ¿Puedo enviar un formulario sin que el usuario pulse en enviar?

Cita:
Iniciado por GatorV Ver Mensaje
He leido el enlace GatorV, sin embargo no se que hago mal, en principio, entiendo que me lo has pasado porque puedo enviar los datos a una URL por POST mediante CURL, correcto?

Este es el código que utilizo para enviar por POST los datos al servidor y no me muestra ningun error ni por pantalla ni en el fichero de logs

Código php:
Ver original
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4. </head>  
  5. <body >
  6.  
  7. <?
  8. $url = "https://sis.sermepa.es/sis/realizarPago"; // escrbe aqui la url de tu formulario
  9. $ch = curl_init(); // Inicializo el handler de Curl
  10.  
  11. //Seteo las opciones para el envio
  12. curl_setopt($ch, CURLOPT_URL,$url); // Url a donde se va a postea.
  13. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'); //Seteo el user Agent en este caso es el navegador firefox 2
  14. curl_setopt($ch, CURLOPT_FAILONERROR, 1); //terminar en caso de error
  15. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// Permitir Redirecciones
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Retornar la pagina de resultados en una variable
  17. curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout.
  18. curl_setopt($ch, CURLOPT_POST, 1); // SETEAR el Envio por POST
  19.  
  20. /* valores TPV */
  21. $postvalue['Ds_Merchant_Order'] = '12421415'; //Pedido
  22. $postvalue['Ds_Merchant_Amount'] = '1000'; //Importe
  23. $postvalue['Ds_Merchant_Currency'] = '978'; //Moneda
  24. $postvalue['Ds_Merchant_MerchantCode'] = 'xxxxxx'; // FUC
  25. $postvalue['Ds_Merchant_MerchantName'] = 'xxxxxxxxxxxxx'; // Comercio
  26. $postvalue['Ds_Merchant_ConsumerLanguage'] = '1'; //Idioma
  27. $postvalue['Ds_Merchant_Terminal'] = '1'; //Terminal
  28. $postvalue['Ds_Merchant_MerchantSignature'] = 'xxxxxxxx'; //Clave
  29. $postvalue['DS_Merchant_TransactionType'] = '0'; //Tipo de transaccion
  30.  
  31. curl_setopt($ch, CURLOPT_POSTFIELDS, $postvalue); //cambia aqui por tu nombre de formulario y datos
  32. $result = curl_exec($ch); // Ejecutar el envio por post.
  33. curl_close($ch); // Cierro la consulta
  34.  
  35. $header['errno']   = $err;
  36. $header['errmsg']  = $errmsg;
  37. $header['content'] = $content;
  38.  
  39. print_r($header);
  40.    
  41. ?>
  42. </body>
  43. </html>

Array ( [errno] => [errmsg] => [content] => )

¿Qué estoy haciendo mal?

Muchas gracias de antemano