0

What am I doing wrong here? ... I'm trying to do a simple get request in php. Why isn't there a Chuck Norris joke being echo'd? $output appears to be a boolean false for some reason.

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.chucknorris.io/jokes/random');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

if(curl_errno($ch)){
    echo 'Curl error: ' . curl_error($ch);
}

$output = curl_exec($ch);

#print_r(curl_getinfo($ch));

curl_close($ch);

$jsonArrayResponse = json_decode($output);

echo $jsonArrayResponse;

?>

1 Answers1

0

Solved it, curl_errno($ch) had to be after curl_exec($ch)

which pointed me to:

PHP - SSL certificate error: unable to get local issuer certificate