Перевести командную строку curl в PHP curl - PullRequest
0 голосов
/ 20 января 2020

Мне нужна помощь в переводе команды curl в PHP команду curl

curl -vvvv -k -s -X POST --header 'Content-type: text/xml;charset="utf-8"' --header 'SOAPAction: vend' -u 'root':'1234' -d "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body><vend xmlns=\"http://service.vti.co.uk/xsd\"><sequence>8076922343</sequence><origMsisdn>01166623832 </origMsisdn><destMsisdn>032030303</destMsisdn><amount>10</amount><tariffTypeId>1</tariffTypeId></vend></soapenv:Body></soapenv:Envelope>" https://121.200.1.223:443/services/vti ; echo;

Я попробовал приведенный ниже код, и он дает мне Error:SSL: no alternative certificate subject name matches target host name, хотя он хорошо работает на терминале.

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://121.200.1.223:443/services/vti');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body><vend xmlns=\"http://service.vti.co.uk/xsd\"><sequence>8076922343</sequence><origMsisdn>01166623832 </origMsisdn><destMsisdn>032030303</destMsisdn><amount>10</amount><tariffTypeId>1</tariffTypeId></vend></soapenv:Body></soapenv:Envelope>");
curl_setopt($ch, CURLOPT_USERPWD, 'root' . ':' . ''1234'');

$headers = array();
$headers[] = 'Content-Type: text/xml;charset=\"utf-8\"';
$headers[] = 'Soapaction: vend';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
...