我们如何使用 Lyft Webhooks 获取司机行程状态?
Posted
技术标签:
【中文标题】我们如何使用 Lyft Webhooks 获取司机行程状态?【英文标题】:How can we use Lyft Webhooks for driver trip status? 【发布时间】:2018-10-09 07:48:44 【问题描述】:我可以在司机帐户中使用 webhook 获取行程状态和数据吗?我已经尝试过,但在 webhook URL 中没有得到任何响应,我们尝试使用实时 lyft 帐户但仍然没有任何响应。
如果有人有解决此问题的方法,请提供帮助。 期待回复。
谢谢,提前!
【问题讨论】:
【参考方案1】:是的,有两种方法可以获取行程状态。
确保您在应用设置中设置了 Webhook URL:
当 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
【讨论】:
以上是关于我们如何使用 Lyft Webhooks 获取司机行程状态?的主要内容,如果未能解决你的问题,请参考以下文章