将命令行curl转换为PHP curl

问题描述 投票:0回答:1

我需要帮助将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);
php curl php-curl
1个回答
0
投票
您尝试过吗?

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

© www.soinside.com 2019 - 2024. All rights reserved.