Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/05/2010, 05:40
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 1 mes
Puntos: 20
Respuesta: Se puede enviar datos con CURL a paginas ASP?

Un nuevo intento sin éxito...

Código PHP:
Ver original
  1. <?php
  2.    
  3. $cookietmp='.';
  4. $target_url = "https://www.bookingh10hotels.com";
  5.  
  6. $ch = curl_init();
  7. curl_setopt($ch, CURLOPT_URL, $target_url);
  8. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookietmp);
  9. curl_setopt($ch, CURLOPT_FAILONERROR, true);
  10. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  11. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  14. curl_setopt($ch, CURLOPT_TIMEOUT, 180);
  15. $html = curl_exec($ch);
  16.  
  17. /* Una vez llegados aqui, interesa enviar el formulario siguiente por POST */
  18. $target2_url="https://www.bookingh10hotels.com/reservasweb/cargar_grupo_codPromo_post.asp";
  19.  
  20. $fields = array(
  21.     'CodPromocion'=>"1234"
  22.     );
  23.  
  24. foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
  25. rtrim($fields_string,'&');
  26.  
  27. $ch = curl_init();
  28. curl_setopt($ch, CURLOPT_URL, $target2_url);
  29. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookietmp);
  30. curl_setopt($ch, CURLOPT_FAILONERROR, true);
  31. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  32. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  34. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  35. curl_setopt($ch, CURLOPT_TIMEOUT, 180);
  36. curl_setopt($ch, CURLOPT_REFERER,'https://www.bookingh10hotels.com');
  37. curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
  38.  
  39. $html2 = curl_exec($ch);
  40.  
  41. echo "<pre>";
  42. echo $html2;
  43. echo "</pre>";
  44.  
  45. /*
  46.  
  47. <form action="cargar_grupo_codPromo_post.asp" method="POST">
  48.     <tr>
  49.         <td><br><u>Código Promocional</u></td>
  50.     </tr>
  51.     <tr>
  52.         <td colspan=3>Si dispones de un código promocional o de colectivo, introdúcelo aquí. Los códigos promocionales no son acumulables a otras ofertas ni promociones, <br><br></td>
  53.     </tr>
  54.     <tr>
  55.         <td></td>
  56.         <td align="center"><input type="text" name="CodPromocion" maxlength=20 value=""></td>
  57.         <td><input type="submit" class="BotonEnviarPagPresup" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enviar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"></td>
  58.     </tr>
  59. </form>
  60.  
  61. */
  62. ?>

¿Alguna sugerencia para enviar datos a ese formulario?

Muchas gracias de antemano!

Última edición por neodani; 30/05/2010 a las 07:39