Last active
July 2, 2018 08:14
-
-
Save DWboutin/8827402 to your computer and use it in GitHub Desktop.
PHP Curl get content
This file contains hidden or 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 | |
$header = array('Accept-Language: en'); | |
$curl = curl_init(); | |
curl_setopt($curl, CURLOPT_URL, $url); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_HEADER, false); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); | |
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); | |
$data = curl_exec($curl); | |
curl_close($curl); | |
if($httpCode == 200) { | |
return $data; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These lines need to be switched like this, because there cant ba a httpCode before the request was executed.