CURL_INIT GET requests are straightforward once you see a working example. Here’s one:
```php
$ch = curl_init("https://official-joke-api.appspot.com/random_joke");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$joke = curl_exec($ch);
curl_close($ch);
echo $joke;
```
RETURNTRANSFER is essential unless you want the response to print automatically (which is rarely useful).
If you’re tired of cURL’s verbosity, check out HTTPful (a lightweight PHP lib).
```php
$ch = curl_init("https://official-joke-api.appspot.com/random_joke");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$joke = curl_exec($ch);
curl_close($ch);
echo $joke;
```
RETURNTRANSFER is essential unless you want the response to print automatically (which is rarely useful).
If you’re tired of cURL’s verbosity, check out HTTPful (a lightweight PHP lib).
