Advertisement
Guest User

Asd

a guest
Sep 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. class xtCurl{
  4.     public function httpRequest($requestConfig){
  5.         $ch = curl_init();  
  6.         curl_setopt($ch, CURLOPT_USERAGENT, $requestConfig['user_agent']);
  7.         curl_setopt($ch, CURLOPT_AUTOREFERER, false);
  8.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  9.         //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  10.         curl_setopt($ch, CURLOPT_HEADER, 1);
  11.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  12.         curl_setopt($ch, CURLOPT_URL, $requestConfig['url']);
  13.         curl_setopt($ch, CURLOPT_REFERER, $requestConfig['referer']);
  14.         $extra = '';
  15.         if($requestConfig['type'] == 'POST'){
  16.             curl_setopt($ch, CURLOPT_POST, true);  
  17.             curl_setopt($ch, CURLOPT_POSTFIELDS, $requestConfig['form_data']);
  18.             //$extra = 'Content-Length: ' . strlen($requestConfig['form_data']);
  19.  
  20.            
  21.         }
  22.  
  23.         curl_setopt($ch, CURLOPT_REFERER, $requestConfig['referer']);
  24.         curl_setopt($ch, CURLOPT_COOKIEFILE, $requestConfig['cookie_name']);
  25.         curl_setopt($ch, CURLOPT_COOKIEJAR, $requestConfig['cookie_name']);
  26.  
  27.        
  28.  
  29.         $data = curl_exec($ch);
  30.         curl_close($ch);
  31.         return $data;
  32.     }
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement