Использовать встроенный httpClient.
Пример:
/**
* @param array $options Optional array with options:
* "redirect" bool Follow redirects (default true)
* "redirectMax" int Maximum number of redirects (default 5)
* "waitResponse" bool Wait for response or disconnect just after request (default true)
* "socketTimeout" int Connection timeout in seconds (default 30)
* "streamTimeout" int Stream reading timeout in seconds (default 60)
* "version" string HTTP version (HttpClient::HTTP_1_0, HttpClient::HTTP_1_1) (default "1.0")
* "proxyHost" string Proxy host name/address
* "proxyPort" int Proxy port number
* "proxyUser" string Proxy username
* "proxyPassword" string Proxy password
* "compress" bool Accept gzip encoding (default false)
* "charset" string Charset for body in POST and PUT
* "disableSslVerification" bool Pass true to disable ssl check.
* All the options can be set separately with setters.
*/
$options = [
'socketTimeout' => 5,
'streamTimeout' => 15,
];
$httpClient = new \Bitrix\Main\Web\HttpClient($options);
// get-запрос
$response = $httpClient->get('http://site.ru/path/to/url/?query');
// post-запрос
$response = $httpClient->post('http://site.ru/path/to/url/?query', [
'param1' => 'value1',
]);
// head-запрос
$response = $httpClient->head('http://site.ru/path/to/url/?query');
// возможные ошибки
$errors = $httpClient->getError();
// Статус ответа
$errors = $httpClient->getStatus();