Advertisement
Ostap34PHP

Untitled

Sep 30th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.53 KB | None | 0 0
  1. <?php
  2. function postCaptchaForm($q, $continue, $token)
  3.     {
  4. //create array of data to be posted
  5.         $post_data['token'] = $token;
  6.         $post_data['continue'] = $continue;
  7.         $post_data['e'] = $q;
  8.  
  9. //traverse array and prepare data for posting (key1=value1)
  10.         foreach ($post_data as $key => $value) {
  11.             $post_items[] = $key . '=' . $value;
  12.         }
  13.  
  14. //create the final string to be posted using implode()
  15.         echo $post_string = implode('&', $post_items);
  16.  
  17. //create cURL connection
  18.         $curl_connection =
  19.             curl_init("https://www.google.com/sorry/index");
  20.  
  21. //set options
  22.         curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
  23.         curl_setopt($curl_connection, CURLOPT_USERAGENT,
  24.             "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
  25.         curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
  26.         curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
  27.         curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
  28.         curl_setopt($curl_connection, CURLOPT_REFERER, $this->curl_captcha_url);
  29.  
  30.  
  31. //set data to be posted
  32.         curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
  33.  
  34. //perform our request
  35.         echo $result = curl_exec($curl_connection);
  36.  
  37. //show information regarding the request
  38.      /*   print_r(curl_getinfo($curl_connection));
  39.         echo curl_errno($curl_connection) . '-' .
  40.             curl_error($curl_connection);*/
  41.  
  42. //close the connection
  43.         curl_close($curl_connection);
  44.  
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement