Advertisement
joris

CURL - POST

Sep 22nd, 2012
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2. /* STEP 1. let’s create a cookie file */
  3. $ckfile = tempnam ("tmp", "CURLCOOKIE");
  4.  
  5. /* STEP 2. visit the homepage to set the cookie properly */
  6. $ch = curl_init ("http://www.batavia-air.com/");
  7. curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
  8. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  9. $output = curl_exec ($ch);
  10.  
  11. /* STEP 3. visit cookiepage.php */
  12. $ch = curl_init ("http://www.batavia-air.com/public/etiket/includes/class/booking/template/cariBookAjaxPros2.php");
  13. curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
  14. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  15. $output = curl_exec ($ch);
  16.  
  17. /* here you can do whatever you want with $output */
  18. $datatopost = array (
  19.                 "ajax_type" => "non_ajax",
  20.                 "blnthnBerangkatPergi" => "12/12",
  21.                 "jmlInfant" => "0",
  22.                 "jmlPenumpang" => "1",
  23.                 "kalenderPergi" => "",
  24.                 "page" => "booking",
  25.                 "page" => "booking",
  26.                 "radio" => "flight",
  27.                 "ruteBerangkat" => "CGK",
  28.                 "ruteKembali" => "kembali",
  29.                 "ruteTujuan" => "AMQ",
  30.                 "tglBerangkatPergi" => "22",
  31.     );
  32. $ch = curl_init ($output);
  33. curl_setopt ($ch, CURLOPT_POST, true);
  34. curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
  35. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  36. $returndata = curl_exec ($ch);
  37. echo $returndata;
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement