Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function fetchURL($url, &$stats = null, $isPost = false, $postParams = array())
- {
- // Headers
- $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
- $headers[] = 'Accept-Language: bg-BG,bg;q=0.8';
- $headers[] = 'Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.3';
- $headers[] = 'Cache-Control: max-age=0';
- $headers[] = 'Connection: keep-alive';
- // cURL
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.187 Safari/535.1");
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_TIMEOUT, 10);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- // Request type and params
- curl_setopt($curl, CURLOPT_POST, $isPost);
- if ($isPost)
- curl_setopt($curl, CURLOPT_POSTFIELDS, $postParams);
- $cnt = curl_exec($curl);
- $stats = curl_getinfo($curl);
- curl_close($curl);
- // Result
- return $cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement