0

I need help translating the curl command to a PHP curl command

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;

I have tried the code below and it gives me Error:SSL: no alternative certificate subject name matches target host name even though it works well on terminal.

$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);
getunstuck
  • 19
  • 3
  • Does this answer your question? [PHP + curl, HTTP POST sample code?](https://stackoverflow.com/questions/2138527/php-curl-http-post-sample-code) – HP371 Jan 20 '20 at 07:47
  • https://incarnate.github.io/curl-to-php/ – Barmar Jan 20 '20 at 07:50
  • It may be worth the effort learning how to use the SOAP interface - https://stackoverflow.com/questions/11593623/how-to-make-a-php-soap-call-using-the-soapclient-class. – Nigel Ren Jan 20 '20 at 07:51

0 Answers0