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;
?>
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.