CURL을 사용하여 API에 요청을 보내고 있지만 요청을받을 수 없습니다. API는 브라우저에서 직접 호출 할 때 잘 작동합니다.CURL을 사용하여 데이터를 가져 오는 중에 문제가 발생했습니다.
여기
http://api.ean.com/ean-services/rs/hotel/v3/info?cid=55505&minorRev=99&apiKey=5d9cp7nfxruc7p788fvvqpwn&locale=en_US¤cyCode=USD&hotelId=123912
내 CURL 코드가 여기
$post_string1 = "cid=55505&minorRev=99&apiKey=5d9cp7nfxruc7p788fvvqpwn&locale=en_US¤cyCode=USD&type=xml&hotelId=123912";
$path1 = "http://api.ean.com/ean-services/rs/hotel/v3/info"; //Relative path to the file with $_POST parsing
$ch1 = curl_init($path1);
$fp1 = fopen('hotel.xml','w');
curl_setopt($ch1, CURLOPT_POSTFIELDS, $post_string1); //Send the data to the file
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Accept: application/xml'));
curl_setopt($ch1, CURLOPT_HEADER, 0);
curl_setopt($ch1, CURLOPT_FILE, $fp1);
$val = curl_exec($ch1);
$info = curl_getinfo($ch1);
curl_close($ch1);//Close curl session
fclose($fp1); //Close file overwrite
//$hotel = simplexml_load_file('hotel.xml');
echo '<pre>';print_r($info);
있는 링크 내가 할 HTTP 405 코드입니다. 제발 내가 뭘 잘못하고 있는지 조언 해주세요.
403 금지 : 자격 증명이 유효하지 않습니다. 저것과 같이 쉬운. –
'$ post_string1'에서 URL을 제거하십시오. 단지 post 매개 변수 만 포함해야합니다. '$ post_string1 = 'cid = 55505 & minorRev = 99 & apiKey = 5d9cp7nfxruc7p788fvvqpwn & locale = en_US & currencyCode = USD & type = xml & hotelId = 123912'; ' – Fracsi
죄송하지만 내 질문을 수정했습니다. 그것의 405 코드. 잘못된 typo : –