Skip to content

Instantly share code, notes, and snippets.

@chuckreynolds
Last active August 8, 2019 13:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chuckreynolds/c4962e795e7735b9b47240fb0ed0ae41 to your computer and use it in GitHub Desktop.
Save chuckreynolds/c4962e795e7735b9b47240fb0ed0ae41 to your computer and use it in GitHub Desktop.
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;
@keshon
Copy link

keshon commented Aug 8, 2019

Simple and elegant, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment