Remote::request()
Static method to init this class and send a request
Parameters
Name | Type | Default |
---|---|---|
$url * | string |
– |
$params | array |
[ ] |
Return type
Exceptions
Type | Description |
---|---|
Exception |
when the curl request failed |
Parent class
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 |
General examples
GET request
More example see Remote::get()
You can also find examples in other parts of our documentation:
- Virtual pages: Content from API
- Virtual pages: Content from an RSS feed
- My first Panel area
- Virtual files: Images from Unsplash API
Kirby API Examples
Note that for the API examples to work, HTTP Basic auth must be enabled in your config.
If you are testing this locally without HTTPS enabled, you also have to set the allowInsecure
config option.