Last active
August 29, 2015 14:16
-
-
Save fdcore/55baf346b9d72d31c679 to your computer and use it in GitHub Desktop.
Use CURL in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function curl_get_file_contents($URL) | |
{ | |
$c = curl_init(); | |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($c, CURLOPT_URL, $URL); | |
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:37.0) Gecko/20100101 Firefox/37.0'); | |
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($c, CURLOPT_VERBOSE, true); | |
curl_setopt($c, CURLOPT_RETURNTRANSFER, true); | |
$contents = curl_exec($c); | |
curl_close($c); | |
if ($contents) return $contents; | |
else return FALSE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment