/ Published in: PHP
Expand |
Embed | Plain Text
/** * Basic cURL wrapper function for PHP * @link http://snipplr.com/view/51161/basic-curl-wrapper-function-for-php/ * @param string $url URL to fetch * @param array $curlopt Array of options for curl_setopt_array * @return string */ $ch = curl_init(); CURLOPT_TIMEOUT => 2, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 AlexaToolbar/alxf-1.54 Firefox/3.6.13 GTB7.1" ); curl_setopt_array($ch, $curlopt); $response = curl_exec($ch); if($response === false) curl_close($ch); return $response; }
You need to login to post a comment.
