I didn’t realise that - that’s a little annoying, as it means V8 code with documented helpers isn’t backwards compatible. The documentation needs updating then.
I do appreciate the decision to change to Guzzle though - it’s very well established and documented, and used in many other libraries and systems.
Yep, your example matches what I’ve just been adjusting, which looks pretty much like this now:
$baseURL = "https://someurl";
$data = ['foo'=>'bar'];
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$version = $app->make('config')->get('concrete.version');
if (version_compare($version, '9.0', '<')) {
$client = $app->make('http/client/curl');
$client->setMethod('POST');
$client->setEncType('application/json');
$client->setRawBody(json_encode($data);
$client->setUri($baseURL);
$response = $client->send();
$returnBody = $response->getBody();
} else {
$client = new \GuzzleHttp\Client();
$headers = ['json'=> $data];
$response = $client->request('POST', $baseURL);
$returnBody = $response->getBody()->getContents();
}
$return = json_decode($returnBody, true);
There might be a better way to test for v9, but I think this is at least clear as an example.
I don’t think you would access php://input
with Guzzle as its for remote calls. php://input
is really just a low-level way of accessing request data.