Skip to content

Kirby 4.3.0


Static method to send a GET request

Remote::get(string $url, array $params = [ ]): Kirby\Http\Remote


Name Type Default
$url * string
$params array [ ]

Return type



Type Description
Exception when the curl request failed

Parent class


Remote::get() is a shortcut for Remote::request() with method GET.

Params array

Default parameters:

Key Type Default Description
agent string null The user agent string to be sent with the HTTP request
basicAuth string null User name and password to use for the Authorization header (formatted as USERNAME:PASSWORD)
body bool true When true returns transfer as string instead of outputting it directly
ca int|bool|string Remote::CA_INTERNAL TLS CA to use, see details
data array|string [] The data to be sent with the request
encoding string utf-8 Accepted values: null, '', identity, gzip, br
file string null Path to file to be uploaded
headers array [] Array of headers to be sent with the request
method string GET HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD)
progress callback null A callback which accepts 5 parameters, if you want to handle upload/download progress
test bool false When set to true, the cURL request is not initiated, and the Remote object returned
timeout int 10 Request/connect timeout


In this example, we make a GET request to the free placekitten API, and write the content of the requested image to file:

$targetPage = page('home');
$response    = Remote::get('');
if ($response->code() === 200) {
    F::write($targetPage->root() . '/kitten.jpg', $response->content());
$response = Remote::get('');
if ($response->code() === 200): ?>
    <?php $character = $response->json(); ?>
        <dd><?= $character['name'] ?></dd>
        <dd><?= $character['status'] ?></dd>
        <dd><?= $character['gender'] ?></dd>
        <dd><?= $character['type'] ?></dd>
<?php endif ?>