【发布时间】:2014-10-15 13:44:24
【问题描述】:
我遇到了获取 curl 响应的问题
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<MMTHotelSearchRequest Offset="0" Rows="500">
<POS>
<Requestor type="B2BAgent" idContext="AFF" id="AFF13856" channel="B2BWeb"/>
<Source iSOCurrency="INR"/>
</POS>
<RequestHotelParams>
<CityCode>DEL,XRO</CityCode>
</RequestHotelParams>
<RequiredFields>hotelInfo,facilitiesInfo,areaInfo,contactInfo,roomsInfo,mediaInfo</RequiredFields>
</MMTHotelSearchRequest>
<?php
$filename = "test.xml";
$handle = fopen($filename, "r");
$xml = fread($handle, filesize($filename));
fclose($handle);
$url = "https://apim-gateway.mmtcloud.com/mmt-htlsearch/1.0/staticsearch/v1.0/hotelData";
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($xml),
);
$soap_do = curl_init();
curl_setopt($soap_do, CURLOPT_URL, $url);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($soap_do, CURLOPT_TIMEOUT, 60);
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST, true );
curl_setopt($soap_do, CURLOPT_POSTFIELDS, $xml);
curl_setopt($soap_do, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($soap_do);
print_r($result);
?>
我遇到了错误
HTTP 状态 415 -
输入状态报告
消息
说明服务器拒绝了这个请求,因为请求实体的格式不被请求的方法所请求的资源所支持。
请帮帮我。
【问题讨论】:
标签: php curl http-status-code-415