Advertisement
Guest User

Untitled

a guest
May 12th, 2011
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. private function curl($url, $post_param = null)
  2.     {
  3.       $ch = curl_init();
  4.       $fh = fopen('curl.txt', 'a+');
  5.       curl_setopt($ch, CURLOPT_STDERR, $fh);
  6.       curl_setopt($ch, CURLOPT_VERBOSE, 1);
  7.  
  8.       if($post_param != null)
  9.       {
  10.         curl_setopt($ch, CURLOPT_HTTPHEADER, array
  11.         (
  12.           'Host'             => 'tld.com',
  13.           'User-Agent'       => 'Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1',
  14.           'Accept'           => 'application/json, text/javascript, */*; q=0.01',
  15.           'Accept-Language'  => 'en-us,en;q=0.5',
  16.           'Accept-Encoding'  => 'gzip, deflate',
  17.           'Accept-Charset'   => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
  18.           'Keep-Alive'       => '115',
  19.           'Connection'       => 'keep-alive',
  20.           'X-Requested-With' => 'XMLHttpRequest',
  21.           'Referer'          => 'http://tld.com/sendlogin.php'
  22.         ));
  23.       }
  24.       else
  25.         curl_setopt($ch, CURLOPT_COOKIE, 'hellobar_current=1300711502; hellobar_1300711502_variation=11462');
  26.  
  27.       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  28.       curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
  29.       curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
  30.       curl_setopt($ch, CURLOPT_URL, $url.'?'.$post_param);
  31.       $html = curl_exec($ch);
  32.       curl_close($ch);
  33.       fclose($fh);
  34.       return $html;
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement