stefana
stefana

Reputation: 2626

curl always returning false

The following code always echos false. Am I missing something?

$url = "https://www.google.nl/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch)) {
    echo "true";
}else{
    echo "false";
}

Upvotes: 2

Views: 2754

Answers (1)

Add this cURL param. That is because , Google runs on Secure HTTP.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Upvotes: 2

Related Questions