/ Published in: PHP
Little function to open an URL using cURL. @params $url - the URL to open @params $cookie [optional] - the path where cookie is (see my other function openCookie()) @return string with the URL contents
Expand |
Embed | Plain Text
function openURL($url,$cookie='') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); if($cookie!='') { // set the cookie file curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Acessar a URL e retornar a saĆda $output = curl_exec($ch); // liberar curl_close($ch); return $output; }
You need to login to post a comment.
