使用优步获取用户终点位置 API
Get Users end point location using Uber API
我一直在看 UBER API,我想知道是否有办法在我的 Android / iOS 应用程序中提供服务 运行 ,我的应用可以在其中获取用户下车位置。
我现在的想法是以下场景:
- 用户乘坐优步汽车前往目的地
- 我的应用程序收到关于下车位置(lat,long)位置的通知
- 我的应用通过通知建议他们在下车地点附近可以做的事情。
这样的用例可能吗?
我对this API
感兴趣
特别是在这个信息中:
"destination":{
"latitude":37.7766874,
"longitude":-122.394857,
"eta":19
}
谢谢。
这样的用例是可能的,并在以下链接中有更详细的解释:
- Uber Trip Experiences documentation
- Uber Developers Blog - Uber Trip Experiences
- Uber News Room - Introducing Uber Trip Experiences
要构建此旅行体验,您必须向用户请求 all_trips OAuth scope:
all_trips
Get details of the trip that the user is currently taking, regardless
of how it was requested (via the Uber app or a third-party
application).
Privileged
这是一个特权范围,因为您需要先向 Uber 请求访问权限,才能在您在 Uber Developer Dashboard
中定义的应用程序中使用该范围
然后在您使用 POST /v1/requests, you can call either the GET /v1/requests/current or GET /v1/requests/{request_id} 代表用户发出优步乘车请求以获取行程详细信息后:
{
"request_id":"17cb78a7-b672-4d34-a288-a6c6e44d5315",
"status":"accepted",
"location":{
"latitude":37.7886532015,
"longitude":-122.3961987534,
"bearing":135
},
"pickup":{
"latitude":37.7872486012,
"longitude":-122.4026315287,
"eta":5
},
"destination":{
"latitude":37.7766874,
"longitude":-122.394857,
"eta":19
},
"driver": {
"phone_number": "(555)555-5555",
"rating": 5,
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
"name": "Bob"
},
"vehicle":{
"make": "Bugatti",
"model": "Veyron",
"license_plate": "I<3Uber",
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
},
"surge_multiplier":1.0,
"eta": 5
}
如果您的应用不发出乘车请求,您必须轮询 GET /v1/requests/current endpoint. See this and this 以获得最佳做法。
如果您的应用发出乘车请求,上述 /v1/requests 端点可以与 Webhooks event driven mechanism, so that you are notified on your server that a trip's status has been updated 结合使用或收据准备就绪,而不是您必须每 3- 5 秒获取最新的详细信息。
当您通过 webhook 收到优步的通知时,您将调用 GET /v1/requests/current or GET /v1/requests/{request_id} 端点。
然后,您需要使用收到的数据通知您的 Android 服务(通过服务器到客户端的通信机制,例如 websocket、推送通知等)新信息可从 Uber 获得并基于您向用户显示给定您要使用的 'Trip Context' 数据的相关信息,例如:
- 当前位置 (latitude/longitude)
- 上车地点 (latitude/longitude)
- 预计到取车时间(汽车到达时)
- 目的地位置(latitude/longitude)
- 到达目的地的预计到达时间(当用户在车里时)
webhook 收到以下事件:
-
For all Requests made by your application on
behalf of Uber riders, we will make a request to your WEBHOOK URL
whenever its status changes. This can help you notify the user or
change the state of your app to reflect a status change without
continuously polling the /v1/requests endpoint.
-
For all Requests made by your application on behalf of Uber riders we
will make a request to your WEBHOOK URL whenever a Request Receipt is
available. This will allow you to show your user the details of their
fare and how much they were charged as soon as their Receipt is
available. If the rider cancels after the grace period, and they are
charged, a receipt will still be available showing that charge.
To get access to a Request Receipt resource, the user must have
authorized your application to have access to the request_receipt
scope.
我一直在看 UBER API,我想知道是否有办法在我的 Android / iOS 应用程序中提供服务 运行 ,我的应用可以在其中获取用户下车位置。
我现在的想法是以下场景: - 用户乘坐优步汽车前往目的地 - 我的应用程序收到关于下车位置(lat,long)位置的通知 - 我的应用通过通知建议他们在下车地点附近可以做的事情。
这样的用例可能吗?
我对this API
感兴趣特别是在这个信息中: "destination":{ "latitude":37.7766874, "longitude":-122.394857, "eta":19 }
谢谢。
这样的用例是可能的,并在以下链接中有更详细的解释:
- Uber Trip Experiences documentation
- Uber Developers Blog - Uber Trip Experiences
- Uber News Room - Introducing Uber Trip Experiences
要构建此旅行体验,您必须向用户请求 all_trips OAuth scope:
all_trips
Get details of the trip that the user is currently taking, regardless of how it was requested (via the Uber app or a third-party application).
Privileged
这是一个特权范围,因为您需要先向 Uber 请求访问权限,才能在您在 Uber Developer Dashboard
中定义的应用程序中使用该范围然后在您使用 POST /v1/requests, you can call either the GET /v1/requests/current or GET /v1/requests/{request_id} 代表用户发出优步乘车请求以获取行程详细信息后:
{
"request_id":"17cb78a7-b672-4d34-a288-a6c6e44d5315",
"status":"accepted",
"location":{
"latitude":37.7886532015,
"longitude":-122.3961987534,
"bearing":135
},
"pickup":{
"latitude":37.7872486012,
"longitude":-122.4026315287,
"eta":5
},
"destination":{
"latitude":37.7766874,
"longitude":-122.394857,
"eta":19
},
"driver": {
"phone_number": "(555)555-5555",
"rating": 5,
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/img.jpeg",
"name": "Bob"
},
"vehicle":{
"make": "Bugatti",
"model": "Veyron",
"license_plate": "I<3Uber",
"picture_url": "https:\/\/d1w2poirtb3as9.cloudfront.net\/car.jpeg"
},
"surge_multiplier":1.0,
"eta": 5
}
如果您的应用不发出乘车请求,您必须轮询 GET /v1/requests/current endpoint. See this and this 以获得最佳做法。
如果您的应用发出乘车请求,上述 /v1/requests 端点可以与 Webhooks event driven mechanism, so that you are notified on your server that a trip's status has been updated 结合使用或收据准备就绪,而不是您必须每 3- 5 秒获取最新的详细信息。
当您通过 webhook 收到优步的通知时,您将调用 GET /v1/requests/current or GET /v1/requests/{request_id} 端点。
然后,您需要使用收到的数据通知您的 Android 服务(通过服务器到客户端的通信机制,例如 websocket、推送通知等)新信息可从 Uber 获得并基于您向用户显示给定您要使用的 'Trip Context' 数据的相关信息,例如:
- 当前位置 (latitude/longitude)
- 上车地点 (latitude/longitude)
- 预计到取车时间(汽车到达时)
- 目的地位置(latitude/longitude)
- 到达目的地的预计到达时间(当用户在车里时)
webhook 收到以下事件:
-
For all Requests made by your application on behalf of Uber riders, we will make a request to your WEBHOOK URL whenever its status changes. This can help you notify the user or change the state of your app to reflect a status change without continuously polling the /v1/requests endpoint.
-
For all Requests made by your application on behalf of Uber riders we will make a request to your WEBHOOK URL whenever a Request Receipt is available. This will allow you to show your user the details of their fare and how much they were charged as soon as their Receipt is available. If the rider cancels after the grace period, and they are charged, a receipt will still be available showing that charge.
To get access to a Request Receipt resource, the user must have authorized your application to have access to the request_receipt scope.