让用户使用尤伯杯API终点位置 [英] Get Users end point location using Uber API

查看:145
本文介绍了让用户使用尤伯杯API终点位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找的UBER API,我想知道是否有办法在我的Andr​​oid / iOS应用程序,在那里我的应用程序可以让用户投递地点运行的服务。

现在我想它的方式是以下情况:
- 用户处于UBER汽车要目的地
- 我的应用程序得到通知落客地点(纬度,经度)的位置
- 我的应用程序显示的东西,他们可以围绕自己的还车地点做,通过通知

就是这样一个用例可能的?

我感兴趣的是这个API

特别是在这样的信息:
目的地:{
      纬度:37.7766874,
      东经: - 122.394857,
      埃塔:19
   }

感谢。


解决方案

这样的用例是可能的,在更多的细节在以下链接解释:

要建立你有权要求 all_trips的OAuth范围从用户此行经历:


  

all_trips


  
  

获取用户目前正在旅行的细节,而不管
  它如何被要求(通过Uber应用或第三方
  应用程序)。


  
  

特权


这是一个享有特权的范围,因为它需要你从尤伯杯首先请求访问的应用程序,你在的尤伯杯开发人员信息中心

然后后您使用 POST / V1 /请求代表用户的尤伯杯骑请求,你可以调用的 GET / V1 /请求/电流 GET / V1 /请求/ {} REQUEST_ID 拿到的行程细节

  {
   REQUEST_ID:17cb78a7-b672-4d34-A288-a6c6e44d5315,
   状态:接受,
   位置:{
      纬度:37.7886532015,
      东经: - 122.3961987534,
      轴承:135
   },
   捡起:{
      纬度:37.7872486012,
      东经: - 122.4026315287,
      埃塔:5
   },
   目的地:{
      纬度:37.7766874,
      东经: - 122.394857,
      埃塔:19
   },
   司机:{
      PHONE_NUMBER:(555)555-5555
      评级:5,
      picture_url:HTTPS:\\ / \\ / d1w2poirtb3as9.cloudfront.net \\ /img.jpeg
      名:鲍勃
   },
   车辆:{
      做:布加迪
      模特:威龙
      license_plate:I< 3Uber
      picture_url:HTTPS:\\ / \\ / d1w2poirtb3as9.cloudfront.net \\ /car.jpeg
   },
   surge_multiplier:1.0,
   埃塔:5
}


  • 如果您的应用程序不作搭车请求,你必须轮询 GET / V1 /请求/电流端点。请参见并的这个最佳做法。


  • 如果您的应用程序,使得搭车请求,上面/ V1 /请求端点可以用结合网络挂接事件驱动机制,使您在您的服务器上通知之旅的的状态已更新或收据已准备就绪,而不是你不必每3-5秒轮询以获得最先进的最新信息成为可能。


当您通过网络挂接从尤伯杯收到通知你,然后调用 GET / V1 /请求/电流 GET / V1 /请求/ {} REQUEST_ID端点

然后你收到你需要告知你的Andr​​oid服务(通过服务器向客户端的通信机制,如WebSocket的,推送通知等),新的信息可以从尤伯杯,并根据您展示给用户的数据相关资料给你想要使用,如'旅行上下文数据:结果
- 当前位置(经度/纬度)结果
- 取货地点(经/纬度)结果
- ETA皮卡(当车到达)结果
- 目标位置(经度/纬度)结果
- ETA至目的地(当用​​户是在汽车)

网络挂接收到以下事件:


  • REQUESTS.STATUS_CHANGED


      

    有关您申请的所有请求
      代表尤伯杯的车手,我们将会对您的网络挂接URL的请求
      每当状态更改。这可以帮助您通知用户或
      改变你的应用程序的状态,以反映状态更改,恕不
      不断轮询/ V1 /请求端点。



  • REQUESTS.RECEIPT_READY


      

    有关您的应用程序代表尤伯杯车友提出的所有要求,我们
      会主动要求到你网络挂接网址只要有请求收据
      可用。这将允许你展现你的用户的详细信息,其
      票价多少,他们只要他们的收据是被指控
      可用。如果车手宽限期后取消,他们是
      收取,收据仍然可用表明收费。


      
      

    要获得访问请求收据资源,用户必须拥有
      授权您的应用程序可以访问request_receipt
      范围。



尤伯杯要求各国

I've been looking at the UBER API and i was wondering if there was a way to have a service running in my Android / iOS app, where my app could get the users drop-off location.

The way i'm thinking about it now is the following scenario: - The user is in a UBER car going to destination - My app gets notified of the drop off location(lat,long) location - My app suggests things that they can do around their drop off location, via a notification.

Is such a use case possible ?

I am interested in this API

Particularly in this information: "destination":{ "latitude":37.7766874, "longitude":-122.394857, "eta":19 }

Thanks.

解决方案

Such a use case is possible and explained in more details in the following links:

To build this trip experience you have to request the all_trips OAuth scope from the user:

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

It is a privileged scope because it is required that you request access first from Uber for the scope to be usable in the application you defined in the Uber Developer Dashboard

Then after you make an Uber ride request on behalf of the user using the POST /v1/requests, you can call either the GET /v1/requests/current or GET /v1/requests/{request_id} to get the details of the trip:

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

  • If your app doesn't make ride requests, you have to poll the GET /v1/requests/current endpoint. See this and this for best practices.

  • If your app makes ride requests, the above /v1/requests endpoints can be combined with the Webhooks event driven mechanism, so that you are notified on your server that a trip's status has been updated or the receipt is ready, instead of you having to poll every 3-5 seconds to get the most up-to-date details possible.

When you receive a notification from Uber via webhooks you then call the GET /v1/requests/current or GET /v1/requests/{request_id} endpoint.

Then with the data you received you need to inform your Android service (by a server to client communication mechanism, e.g. websocket, push notifications, etc.) that new information is available from Uber and based on that you show to the user relevant information given the 'Trip Context' data you want to use, e.g.:
- Current location (latitude/longitude)
- Pickup location (latitude/longitude)
- ETA to pickup (while the car is arriving)
- Destination location (latitude/longitude)
- ETA to destination (while the user is in the car)

The webhook receives the following events:

  • REQUESTS.STATUS_CHANGED

    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.

  • REQUESTS.RECEIPT_READY

    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.

这篇关于让用户使用尤伯杯API终点位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆