Sending HTTP Requests
Prerequisites: Authentication & password hashing
file_get_contents can fetch a URL directly for simple cases;
cURL (or the Guzzle package, built on it) gives full control
over headers, methods, and error handling for real applications.
$ch = curl_init('https://api.example.com/users');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($response, true);
In a Composer-based project, guzzlehttp/guzzle wraps this in a
much friendlier API ($client->get($url)) — worth reaching for
once a project has real HTTP needs beyond a single quick request.