Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

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
You can’t perform that action at this time.