我们如何使用Lyft Webhooks获取驾驶员出行状态?

时间:2018-10-09 07:48:45

标签: webhooks lyft-api

我可以使用驱动程序帐户中的webhook来获取旅行状态和数据吗?我已经尝试过,但是在webhook URL中没有收到任何响应,我们尝试使用实时lyft帐户,但仍然没有任何响应。

如果有人可以解决此问题,请提供帮助。 期待得到答复。

谢谢,谢谢!

1 个答案:

答案 0 :(得分:0)

是的,有两种获取行程状态的方法。

确保在应用设置中设置了Webhook URL:

Webhook Url textfield in Lyft App Settings

当Webhook发布时,json看起来类似于:

    {
  "event_id": "ed595871-6b2f-5b22-99ae-a848ee763701",
  "href": "https://api.lyft.com/v1/rides/123456789",
  "occurred_at": "2017-07-26T11:03:50+00:00",
  "event_type": "ride.status.updated",
  "event": {
    "origin": {
      "lat": 37.76734,
      "lng": -122.40626,
      "eta_seconds": 60,
      "address": null
    },
    "passenger": {
      "rating": "5",
      "first_name": "John",
      "last_name": "Doe",
      "image_url": "https://lyft-app-img.s3.amazonaws.com/production/profilePicture/12345",
      "user_id": "123456789"
    },
    "requested_at": "2017-07-26T18:03:38+00:00",
    "route_url": "https://www.lyft.com/sr/abcdefg",
    "ride_id": "123456789",
    "destination": {
      "lat": 37.77653,
      "lng": -122.39215,
      "eta_seconds": null,
      "address": null
    },
    "driver": {
      "phone_number": "+15555555555",
      "rating": "4.9",
      "first_name": "Jane",
      "image_url": "https://lyftapi.s3.amazonaws.com/production/photos/320x200/123456_driver.jpg"
    },
    "can_cancel": [
      "driver",
      "passenger",
      "dispatcher"
    ],
    "status": "accepted",
    "location": {
      "lat": 37.765975,
      "bearing": 270,
      "lng": -122.406034
    },
    "generated_at": "2017-07-26T18:03:50+00:00",
    "vehicle": {
      "color": "Red",
      "make": "Chevy",
      "license_plate": "ABCDEFG",
      "image_url": "https://s3.amazonaws.com/lyftapi/production/photos/stockcarphotos/whitebg/640x400/2015/chevy/bolt/red/12345.png",
      "year": 2015,
      "license_plate_state": "CA",
      "model": "Bolt"
    },
    "ride_type": "lyft",
    "pricing_details_url": "https://www.lyft.com/pricing/SFO",
    "ride_profile": "personal"
  }
}

您可以从此处选择webhook.status。

第二种方法是通过GET / ride /:id端点长时间轮询旅程。这也将使您获得ride.status。

在线参考: https://developer.lyft.com/v1/reference#ride-request-details

可能的乘车状态: https://developer.lyft.com/docs/ride-states