0PricingLogin
PHP Academy · Lesson

Making HTTP Requests with cURL

Use cURL to perform GET and POST requests to external APIs.

What is cURL?

cURL is a library for transferring data with URLs. PHP wraps it in the curl_* functions, making it the standard way to call external APIs.

Basic GET Request

Initialise a cURL handle, set options, execute, and close.

<?php
$ch = curl_init("https://api.example.com/users");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;

All lessons in this course

  1. JSON Encoding and Decoding
  2. Making HTTP Requests with cURL
  3. Handling API Responses and Errors
  4. Building a Simple API Client
← Back to PHP Academy