0

我可以在司机帐户中使用 webhook 获取行程状态和数据吗?我已经尝试过,但在 webhook URL 中没有得到任何响应,我们尝试使用实时 lyft 帐户,但仍然没有任何响应。

请帮忙,如果有人有解决这个问题的方法。期待回复。

提前致谢!

4

1 回答 1

0

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

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

Lyft 应用程序设置中的 Webhook 网址文本字段

当 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

于 2018-12-12T21:46:06.377 回答