Php Sabre get酒店图像API
我对Sabre get hotel image API有问题 我在发出请求时收到以下响应。由于没有访问权限,授权失败。请参阅下面的完整回复Php Sabre get酒店图像API,php,sabre,Php,Sabre,我对Sabre get hotel image API有问题 我在发出请求时收到以下响应。由于没有访问权限,授权失败。请参阅下面的完整回复 array(5) { ["status"]=> string(12) "NotProcessed" ["type"]=> string(10) "Validation" ["errorCode"]=> string(26) "ERR.2SG.SEC.NOT_AUTHORIZED" ["timeStamp"]=> string(29)
array(5) { ["status"]=> string(12) "NotProcessed" ["type"]=> string(10) "Validation" ["errorCode"]=> string(26) "ERR.2SG.SEC.NOT_AUTHORIZED" ["timeStamp"]=> string(29) "2016-10-20T04:28:54.500-05:00" ["message"]=> string(48) "Authorization failed due to no access privileges" }
下面是我的代码有什么问题
<?php
// get access token
$client_id= base64_encode("V1:user:group:AA");
$client_secret = base64_encode("my_password");
$token = base64_encode($client_id.":".$client_secret);
$data='grant_type=client_credentials';
$headers = array(
'Authorization: Basic '.$token,
'Accept: */*',
'Content-Type: application/x-www-form-urlencoded'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://api.sabre.com/v2/auth/token");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$resf = json_decode($res,1);
$access_token = $resf['access_token']; // token provided from sabre
$token_type = $resf['token_type'];
$expires_in_seconds = $resf['expires_in'];
// // END get access token
// now to get api data using the provided access token
$url = 'https://api.sabre.com/v1.0.0/shop/hotels/image?mode=image';
$headers2 = array(
'Authorization: bearer '.$access_token,
'protocol: HTTP 1.1 ',
"Content-Type: application/json"
);
$postData ='{
"GetHotelImageRQ": {
"HotelRefs": {
"HotelRef": [
{
"HotelCode": "1276",
"CodeContext": "Sabre"
}
]
},
"ImageRef": {
"Type": "THUMBNAIL",
"CategoryCode": 3,
"LanguageCode": "EN"
}
}
}';
$ch2 = curl_init();
curl_setopt($ch2,CURLOPT_HTTPHEADER,$headers2);
curl_setopt($ch2, CURLOPT_URL, $url);
curl_setopt($ch2, CURLOPT_POST, TRUE);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $postData);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
var_dump( $results = json_decode(curl_exec($ch2),true));
?>
该服务似乎需要激活。 从API规范页面: “注意:此服务目前仅在有限的地区(美洲和EMEA)提供,需要激活。请与您的Sabre帐户代表联系以获得帮助。”
您可以通过或Web服务请求激活测试。support@sabre.com该服务似乎需要激活。 从API规范页面: “注意:此服务目前仅在有限的地区(美洲和EMEA)提供,需要激活。请与您的Sabre帐户代表联系以获得帮助。”
您可以通过或Web服务请求激活测试。support@sabre.com谢谢,我会联系他们的。谢谢,我会联系他们的。