Php 为什么响应显示REST服务请求为空

Php 为什么响应显示REST服务请求为空,php,json,rest,curl,Php,Json,Rest,Curl,我正在为实施在线酒店预订而提供休息服务。根据REST服务提供商的说法,我们需要发送带有JSON格式输入的REST请求。根据服务提供商文件,JSON格式为: { "ResultIndex": "1", "HotelCode": "128407", "HotelName": "Nieuw Slotania Hotel", "GuestNationality": "IN", "NoOfRooms": 4, "ClientReferenceNo": 0, "HotelRoomsDetails": [ {

我正在为实施在线酒店预订而提供休息服务。根据REST服务提供商的说法,我们需要发送带有JSON格式输入的REST请求。根据服务提供商文件,JSON格式为:

{
"ResultIndex": "1",
"HotelCode": "128407",
"HotelName": "Nieuw Slotania Hotel",
"GuestNationality": "IN",
"NoOfRooms": 4,
"ClientReferenceNo": 0,
"HotelRoomsDetails": [
{
"RoomIndex": "1",
"RoomTypeCode": "Xv+rPD4t1XERkUWumdalig==|ST|CG-FIT|221###",
"RoomTypeName": "DOUBLE STANDARD",
"RatePlanCode": "BB-E10",
"BedTypeCode": null,
"SmokingPreference": 0,
"Supplements": null,
"Price": {
"CurrencyCode": "INR",
"RoomPrice": "9518.05",
"Tax": "0.0",
"ExtraGuestCharge": "0.0",
"ChildCharge": "0.0",
"OtherCharges": "0.0",
"Discount": "0.0",
"PublishedPrice": "9518.05",
"PublishedPriceRoundedOff": "9518",
"OfferedPrice": "9518.05",
"OfferedPriceRoundedOff": "9518",
"AgentCommission": "0.0",
"AgentMarkUp": "1241.48",
"ServiceTax": "99.32",
"TDS": "0.0"
},
],
"EndUserIp": "123.1.1.1",
"TokenId": "df141129-c8f1-4a56-84ca-14483e148e75",
"TraceId": "625e8d04-afdc-496c-bb43-39ba59554f89"
}
在我们这边,我们使用“curl”执行带有以下JSON输入的web服务: 我们这边使用PHP的JSON输入:

$temp='{
"ResultIndex": "1",
"HotelCode": "'.$_HotelCode.'",
"HotelName": "'.$_HotelName.'",
"GuestNationality": "IN",
"NoOfRooms": 4,
"ClientReferenceNo": 0,
"HotelRoomsDetails": [
{
"RoomIndex": "1",
"RoomTypeCode": "'.$_RoomTypeCode.'",
"RoomTypeName": "'.$_RoomTypeName.'",
"RatePlanCode": "'.$_RatePlanCode.'",
"BedTypeCode": null,
"SmokingPreference": 0,
"Supplements": null,
"Price": {
"CurrencyCode": "INR",
"RoomPrice": "'.$_RoomPrice.'",
"Tax": "'.$_Tax.'",
"ExtraGuestCharge": "0.0",
"ChildCharge": "0.0",
"OtherCharges": "0.0",
"Discount": "0.0",
"PublishedPrice": "'.$_PublishedPrice.'",
"PublishedPriceRoundedOff": "'.$_PublishedPriceRoundedOff.'",
"OfferedPrice": "'.$_OfferedPrice.'",
"OfferedPriceRoundedOff": "'.$_OfferedPriceRoundedOff.'",
"AgentCommission": "'.$_AgentCommission.'",
"AgentMarkUp": "'.$_AgentMarkUp.'",
"ServiceTax": "'.$_ServiceTax.'",
"TDS": "'.$_TDS.'"
}
}
],
"EndUserIp": "192.168.0.1",
"TokenId": "'.$token_id.'",
"TraceId": "'.$_TraceId.'"
}';


WE EXECUTE  IT  AS FOLLOWS:


$resp_hotel_room= (array) ExecuteURL($url,$temp);            

其中ExecuteURL是我们定制的CURL执行函数。输出“$resp_hotel_room”未出现,状态显示为400

请提供ExecuteURL函数ExecuteURL$url$data的实现{$content=json_encode$data;$curl=curl_init$url;curl_setopt$curl,CURLOPT_HEADER,false;curl_setopt$curl,CURLOPT_RETURNTRANSFER,true;curl_setopt$curl,CURLOPT_POST,true;curl_setopt$curl,CURLOPT_POSTFIELDS,$content;$json_response=curl_exec$curl;$status=curl\u getinfo$curl,CURLINFO\u HTTP\u CODE;$json=json\u decode$json\u response;echo Status=.$Status;;curl\u close$curl;return$json;}您可以以格式化的形式将其编辑到原始post中。输入或ExecuteURL函数的JSON格式似乎没有问题,因此错误不是语法错误;可能是使用https时远程端点的服务器证书过期了,或者JSON内容不是有效的请求,即缺少某些ANX。我将检查它。