gpt4 book ai didi

php - 400 - Curl 中的错误请求

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:57:56 25 4
gpt4 key购买 nike

<分区>

当我试图用 php 向服务器发送请求时,我似乎遇到了问题。 http api 请求是这样的:

http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14&apiKey=p9ycn9cxb2zp3k3gfvbf5aym&cid=55505&locale=en_US&hotelId=122212&stateProvinceCode=%20NV%C2%A4cyCode=USD&arrivalDate=12/27/2012&departureDate=12/28/2012&room1=2,&room2=2,18,15&room3=3,16,16,15&room4=3,&includeDetails=true&includeRoomImages=true

我在 php 中有以下部分代码,我认为发生了错误:

$url = 'http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14';
$url .= '&apiKey=p9ycn9cxb2zp3k3gfvbf5aym';
$url .= '&cid=55505';
$url .= '&locale=' . $locale . '&hotelId=' . $hotelid . '&stateProvinceCode=' . $state . '&currencyCode=USD';

$url .= '&arrivalDate=' . $datefr . '&departureDate=' . $dateto . '&' . $details . '&includeDetails=true&includeRoomImages=true';
$header = "Accept: application/json";

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$retValue = curl_exec($ch);
$response = json_decode(curl_exec($ch));
$ee = curl_getinfo($ch);
print_r($ee);

print_r($retValue);

这是我从 print_r(curl_getinfo($ch)) 语句中得到的:

Array (
[url] => http://api.ean.com/ean-services/rs/hotel/v3/avail?minorRev14&apiKey=p9ycn9cxb2zp3k3gfvbf5aym&cid=55505&locale=en_US&hotelId=122212&stateProvinceCode= NV¤cyCode=USD&arrivalDate=12/27/2012&departureDate=12/28/2012&room1=2,&room2=2,18,15&room3=3,16,16,15&room4=3,&includeDetails=true&includeRoomImages=true
[content_type] => text/html
[http_code] => 400
[header_size] => 181
[request_size] => 340
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.469
[namelookup_time] => 0
[connect_time] => 0.125
[pretransfer_time] => 0.125
[size_upload] => 0
[size_download] => 349
[speed_download] => 744
[speed_upload] => 0
[download_content_length] => 349
[upload_content_length] => 0
[starttransfer_time] => 0.469
[redirect_time] => 0
[certinfo] => Array ( )
[redirect_url] =>
)

我不确定解决方案是什么,我已经研究这个问题一段时间了,希望有人能帮助我,谢谢 :)

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com