php - 将命令行 curl 转换为 PHP curl
问题描述
我需要帮助将 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);
解决方案
推荐阅读
- ios - 用于 4k @ 60 FPS 视频录制的 iOS 11 API
- php - PDOStatement::fetch 偶尔返回 false,但 errorInfo() 为空
- c# - 如何让 JWT 在 Autorest 生成的 SDK 中工作?(ASP.NET 核心 2.0)
- php - 使用 PHP 7.1.17 的作曲家(Phar 错误)
- asp.net - Blazor 性能
- angular - Rxjs:如何将相同类型的 Observable 组合成单个 observable
- javascript - React Native - 带有 Flatlist 项目的模态
- python - 保存和导出 python pandas 数据框的 dtypes 信息
- node.js - 在 DialogFlow WebHook 中使用异步函数
- opencv - 同时从多个摄像头捕捉图像