In some projects you may need to use cURL to call remote URLs via GET or POST. The RequestFactory is a core class that simplifies this task.

The RequestFactory uses the PSR-7 standard for requests, responses and streams. Behind the scenes, Guzzle uses the best method available (cURL, sockets, etc), which is even more flexible than simple 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
}