Возвращение вызова API Inquisiq XML 400 - PullRequest
0 голосов
/ 08 февраля 2019

При отправке XML-запроса в API он возвращает 404 неверных запроса.

Я следую Справочному руководству API по запросу: https://www.inquisiq.com/sharedResources/Documents/Inquisiq%20LMS%20API%20Manual.pdf

Мой код:

$url = 'http://degrandson.inquisiqr4.com/_gateway/api/getCatalog.asp';

$post_string = '<?xml version="1.0" encoding="UTF-8"?><serv_request><head><securityContext><account>degrandson</account><key>123456789012</key></securityContext></head><body><id>68375</id></body></serv_request>';


$headers = array(
    'POST HTTP/1.0',
    'Content-type: text/xml',
    //'Content-type: application/xml',
    'Content-length: '.strlen($post_string),
    'Content-transfer-encoding: text',
    'account: degrandson',
    'key: 123456789012',
    'Connection: close',
    $post_string,
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

$data = curl_exec($ch);

var_dump($data);

Результат:

array(2) {
  ["head"]=>
  object(SimpleXMLElement)#2 (1) {
    ["title"]=>
    string(15) "400 Bad Request"
  }
  ["body"]=>
  object(SimpleXMLElement)#3 (2) {
    ["@attributes"]=>
    array(1) {
      ["bgcolor"]=>
      string(5) "white"
    }
    ["center"]=>
    object(SimpleXMLElement)#1 (1) {
      ["h1"]=>
      string(15) "400 Bad Request"
    }
  }
}
...