Uber API GET / requests / {request_id} /收据[message] =>禁止

时间:2017-06-13 20:32:18

标签: uber-api

我正在尝试获取静态地图或过去超级乘车的旅行收据。

$headers = array(
"Authorization: Bearer {$this->token}",
'Accept-Language: en_US',
'Content-Type: application/json'
);
curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.uber.com/v1.2/requests/my-request-id-xxx/receipt');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); // So it doesnt print out results


$curl_results = curl_exec($curl);
curl_close($curl); 

// Uber Responds with JSON
$curl_results = json_decode($curl_results, TRUE); print_r($curl_results);

答案如下:

Array
(
    [message] => Forbidden
    [code] => forbidden
)

我刷新了我的令牌并收到了新的令牌并进行了三次检查,以确保我选择了正确的范围。我知道这是特权范围,我尝试访问的帐户是我自己的帐户。我唯一的解释是,在API帐户下,我的电子邮件被标记为"所有者"而不是"开发人员"。这可能是我被拒绝的原因......还是我犯了另一个错误?

1 个答案:

答案 0 :(得分:1)

对于/v1.2/requests/xxx/map和/v1.2/requests/xxx/receipt的Uber API,如果您的应用未创建请求/事件,则不会使其数据可用。您只能访问/v1.2/history,它提供以下数据:

 {
  "status": "completed",
  "distance": 1.4780860317,
  "product_id": "a1111c8c-c720-46c3-8534-2fcdd730040d",
  "start_time": 1475545183,
  "start_city": {
    "latitude": 37.7749,
    "display_name": "San Francisco",
    "longitude": -122.4194
  },
  "end_time": 1475545808,
  "request_id": "fb0a7c1f-2cf7-4310-bd27-8ba7737362fe",
  "request_time": 1475545095
}

如果您想要特定旅行的更多数据,您唯一的选择是进入用户主页仪表板@ https://riders.uber.com/trips/request_id,复制Google静态地图图像的URL SRC并解码$ _GET [path]参数:(