Answer the question
In order to leave comments, you need to log in
How to implement a PHP post request to accept a response when it is deployed to the same IP as the responding service?
PHP post-request that passes the login and password from the form via CURL and does not receive an XML response from the 1C service when the service is deployed on the same IP. When overgrown with a different IP, everything works on both Windows and Linux ...
if (strlen($_REQUEST['aName']) > 0 and strlen($_POST['aPass']) > 0) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://192.168.0.162/BlaBlaBla/authorization');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "" . $_REQUEST['aName'] . ":" . $_POST['aPass']);
$r_xml = curl_exec($curl);
$dom = new domDocument("1.0", "utf-8");
$dom->loadXML($r_xml);
echo var_dump($r_xml);
// string(448)
// DOMDocument::loadXML() [domdocument.loadxml]: Space required after the Public Identifier in Entity
// 413
// does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit
Answer the question
In order to leave comments, you need to log in
After reading almost 10 current forums, it was decided to abandon CURL, because. when accessing localhost, CURL often does not behave as intended.
As a result, implemented via Http Request:
$url = 'http://192.168.0.162/BlaBlaBla/authorization';
$options = array(
'http' => array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'header' => "Authorization: Basic AbCdEfGhIjHk13452653765==",
'method' => 'POST',
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question