In some projects you need to use cURL to call remote URLs via GET or POST. With the RequestFactory there is a core class to simplify this task.

The RequestFactory uses with Guzzle the PSR-7 standard for requests, responses and also streams. In the background Guzzle uses the best method which is abvailable (cURL, sockets, etc.) and is even more flexible then plain cURL.

RequestFactoryhttps://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Http/Index.html
Guzzlehttps://docs.guzzlephp.org/en/latest/

Example how to switch from cURL to RequestFactory

cURL

<?php
$data = [
	'param1' => 'Nice',
	'param2' => 'here',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://yoururl/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
if ($info['http_code'] == 200) {
	//oleole
}

RequestFactory

<?php
$options = [
	'form_params' => [
		'param1' => 'Nice',
		'param2' => 'here',
	]
];
$requestFactory = GeneralUtility::makeInstance(RequestFactory::class);
$response = $requestFactory->request('https://yoururl', 'POST', $options);
if ($response->getStatusCode() === 200) {
	//oleole
}