【发布时间】:2016-03-10 07:20:55
【问题描述】:
我已经成功地连接到 Sabre 的 RESTful API 并使用我的测试密钥/秘密获取我的身份验证令牌。但是,我正在努力的下一步-我是卷曲的新手,所以请原谅我的无知。谁能告诉我哪里出错了?
$key 是我的 Sabre 生成的身份验证令牌
$url = "https://api.test.sabre.com/v2/shop/flights/fares?origin=ATL&destination=LAS&departuredate=2016-06-30&lengthofstay=3,4,5,6,7&maxfare=250";
$header[] = "Authorization: Bearer " . $key;
$header[] = "Accept: application/json";
//should use http 1.1 by default
//uses GET by default
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
var_dump(json_decode($content));
我认为这可能是错误的 URL。我没有生产 API 密钥,只有一个测试密钥。但是,将 url 更改为生产 URL(删除测试。)并没有什么不同。
这是 Sabre 的错误
object(stdClass)[2]
public 'status' => string 'NotProcessed' (length=12)
public 'type' => string 'Validation' (length=10)
public 'errorCode' => string 'ERR.2SG.SEC.MISSING_CREDENTIALS' (length=31)
public 'timeStamp' => string '2016-03-10T01:17:19.556-06:00' (length=29)
public 'message' => string 'Authentication data is missing' (length=30)`
我是不是把标题弄乱了?
在第 4 步:https://developer.sabre.com/docs/read/rest_basics/authentication 它说标题应该是
授权:持有者{您的令牌}
感谢您的帮助!
【问题讨论】: