Closed
Description
Motivation
Various REST APIs online require JSON with PUT or POST.
Proposed Solution
Support additional options: postfields and customrequest
eg.
$options = [
'postfields' => "{\"email\":\"demo@example.com\", \"name\": \"John\"}",
'customrequest' => 'PUT',
'header' => [
"accept: application/json",
"content-type: application/json"
]
];
$cu = e107::getFile()->initCurl($url, $options);
$result = curl_exec($cu);
or use getRemoteContent() which uses initCurl() and has the error handling built-in.
$options = [
'postfields' => "{\"email\":\"demo@example.com\", \"name\": \"John\"}",
'customrequest' => 'PUT',
'header' => [
"accept: application/json",
"content-type: application/json"
]
];
$result = e107::getFile()->getRemoteContent($url, $options);