Skip to content

Kirby 4.4.1

$remote->content()

Returns the response content

$remote->content(): string|null

Return type

string|null

Parent class

Kirby\Http\Remote

Example

Response content can be in different formats depending on what what is returned from the endpoint.

<?php
$response = Remote::get('https://rickandmortyapi.com/api/character/108');

if ($response->code() === 200) {
    $data = $response->content();
    dump($data);
}

The example will return something like this

{
  "id": 108,
  "name": "Dr. Xenon Bloom",
  "status": "Dead",
  "species": "Humanoid",
  "type": "Amoeba-Person",
  "gender": "Male",
  "origin": {
    "name": "unknown",
    "url": ""
  },
  "location": {
    "name": "Anatomy Park",
    "url": "https://rickandmortyapi.com/api/location/5"
  },
  "image": "https://rickandmortyapi.com/api/character/avatar/108.jpeg",
  "episode": [
    "https://rickandmortyapi.com/api/episode/3"
  ],
  "url": "https://rickandmortyapi.com/api/character/108",
  "created": "2017-12-26T13:14:12.157Z"
}