HotelsPro 웹 서비스에 편안한 요청을 보내는데 문제가 있습니다.인증 자격 증명을 제공하지 않았습니다.
스피 기본 자격 증명이 링크 https://api-test.hotelspro.com:443에 요청을 보내려고하지만 때마다 도와주세요
sub getJSONdata {
my ($SupplierXMLServer, $message, $compressed,$timeOut) =();
($SupplierXMLServer, $message, $compressed,$timeOut) = @_;
$SupplierXMLServer='https://api-test.hotelspro.com/api/v2/search/?destination_code=20b05&checkin=2016-11-09&checkout=2016-11-12¤cy=USD&client_nationality=PS&pax=2';
my $username = "Epilgrim";
my $password = "xxxxxxxxxx";
use LWP::UserAgent;
my $userAgent = LWP::UserAgent->new(agent =>"1");
$userAgent->credentials('https://api-test.hotelspro.com:443', 'api', $username , $password);
$userAgent->timeout($timeOut) if($timeOut); # in seconds
use HTTP::Request::Common;
my $response = '';
if($compressed){
$response = $userAgent->request(GET $SupplierXMLServer,
Content_Type => 'application/json',
Accept_Encoding => "gzip,deflate",
Content => $message);
}
else{
$response = $userAgent->request(GET $SupplierXMLServer,
Content_Type => 'application/json',
Content => $message);
}
return $response->error_as_HTML unless $response->is_success;
#return $response->content;
if($compressed){
return $response->decoded_content;
}
else{
return $response->content;
}
}
에 따라 같은이 자격 증명 있지만 browser.My 코드에 노력하고 있습니다 "인증 자격 증명을 제공하지 않았다"오류 올바른 코드를 작성하고 올바른 응답을 얻기 위해 올바른 방법으로 요청을 보냅니다.
'credentials'을 (를) 호출 할 때 프로토콜을 제거 할 수 있습니까? 'hostname : port'형식이어야합니다. 즉, 'api-test.hotelspro.com : 443'' http : /stackoverflow.com/questions/1799147/why-dont-my-lwpuseragent-credentials-work – ardavey