Last active
August 8, 2019 13:33
-
-
Save chuckreynolds/c4962e795e7735b9b47240fb0ed0ae41 to your computer and use it in GitHub Desktop.
Fetches a dad joke from icanhazdadjoke.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
Simple and elegant, thanks!