Fetches a dad joke from icanhazdadjoke.com
<?php | |
$url = 'https://icanhazdadjoke.com/'; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept:text/plain']); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
echo $data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
keshon commentedAug 8, 2019
Simple and elegant, thanks!