0
votes

I am trying to make a request to get the static map OR trip receipt of a past uber ride.

$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);

The response is this:

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

I've refreshed my token and also received new tokens and triple checked to make sure I had selected the correct scopes. I understand that this is a privilege scope and the account I am trying to access is my own account. My only explanation is to what could be happening is that under the API account my email is marked as "Owner" rather than "developer". Could this be the reason why I am being denied.. or am I making another mistake?

1
After doing more research does this API work for rides that have occurred in past "x" amount of days? Like is it only meant for recently occurring trips? - Jermel
What scopes are you using for that bearer token? - Kyle Davis
In attempt to make this work I've selected every single scope. Im also sending the scopes in the initial HTTP request for user auth to make sure all scopes are being applied. - Jermel
Can you specifically say the scopes you are passing please? Thank you. - Kyle Davis
$scopes = array("history", "request_receipt", "request", "delivery", "history_lite", "places", "profile", "ride_widgets", "all_trips"); $scopes = urlencode(implode(" ", $scopes)); - Jermel

1 Answers

1
votes

Uber API for /v1.2/requests/xxx/map and /v1.2/requests/xxx/receipt does not make their data available if your app did not create the request / event. You only have access to /v1.2/history which provides you the following data:

 {
  "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
}

If you want more data on a particular trip your only option is to go onto the User Home Page dashboard @ https://riders.uber.com/trips/request_id, copy the URL SRC of the Google Static Maps image and decode the $_GET[path] parameter :(