I want to check if a page gives a 200 header using curl.
I am using the following script:
public static function isUrlExist($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_NOBODY, TRUE);
curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code == 200) {
$status = true;
} else {
$status = false;
}
curl_close($curl);
return $status;
}
The strange thing is it evaluates to true if I query a website such as vimeo: https://vimeo.com/api/oembed.json?url=https://vimeo.com/11896354
But websites such as Facebook or Google return false.
Am I missing something?