There is a cloud server with 1C deployed on it. I need to remotely connect to its database from the site. If I manually enter the path https://terminal.scloud.ru/scxxxxsex/ws/Exchange?wsdl in the browser, I am asked to login authorization + password, as in the screenshot:

enter image description here

I enter in the browser and get the correct answer.

But the task - to do the same through php, so that the answer was received and processed on the site. And the problem is that I don’t understand through which variables I need to give my login and password. And in the end, I get an HTTP Error 401.2 - Unauthorized

// создаем подключение $ch = curl_init('https://terminal.scloud.ru/scxxxx_basex/ws/Exchange?wsdl'); // устанавлваем даные для отправки curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); // флаг о том, что нужно получить результат curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // отправляем запрос $response = curl_exec($ch); // закрываем соединение curl_close($ch); 
  • It is necessary to add curl_setopt with the transfer of the login password. Google, there are plenty of examples, if suddenly no one writes a piece of code here. - de_frag

1 answer 1

 curl_setopt($ch, CURLOPT_USERPWD, "логин:пароль"); //и т.к. это http аутентификация curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);