gpt4 book ai didi

android - 在 Android 应用程序上集成 uber API(深度链接)

转载 作者:太空狗 更新时间:2023-10-29 14:03:34 25 4
gpt4 key购买 nike

您好,我想在我的应用程序上集成 Ride 和 uber 按钮。我向 api 发出了请求带参数

'server_token': 'ma***********************u',
'start_latitude',
'start_longitude',
'end_latitude'
'end_longitude'.

我得到了回复:

{
"result": {
"prices": [
{
"currency_code": "INR",
"display_name": "uberGO",
"distance": 18.45,
"duration": 3503,
"estimate": "₹559-720",
"high_estimate": 720,
"localized_display_name": "uberGO",
"low_estimate": 559,
"minimum": 60,
"product_id": "c8170d76-b67c-44b1-8c26-5f45541434d2",
"surge_multiplier": 2
},
{
"currency_code": "INR",
"display_name": "uberGO",
"distance": 18.45,
"duration": 3503,
"estimate": "₹559-719",
"high_estimate": 719,
"localized_display_name": "uberGO",
"low_estimate": 559,
"minimum": 60,
"product_id": "bc46ccfe-de64-4cad-b63a-7cf48e649a3e",
"surge_multiplier": 2
},
{
"currency_code": "INR",
"display_name": "uberX",
"distance": 18.45,
"duration": 3503,
"estimate": "₹834-1,069",
"high_estimate": 1069,
"localized_display_name": "uberX",
"low_estimate": 834,
"minimum": 80,
"product_id": "4da6a747-e0be-4f56-a3c7-3f30f22bf86d",
"surge_multiplier": 2.4
},
{
"currency_code": "INR",
"display_name": "uberGO",
"distance": 18.45,
"duration": 3503,
"estimate": "₹834-1,069",
"high_estimate": 1069,
"localized_display_name": "uberGO",
"low_estimate": 834,
"minimum": 80,
"product_id": "18656d0e-cc1b-4aa6-8146-92e605626caa",
"surge_multiplier": 2.4
},
{
"currency_code": "INR",
"display_name": "uberXL",
"distance": 18.45,
"duration": 3503,
"estimate": "₹1,646-2,099",
"high_estimate": 2099,
"localized_display_name": "uberXL",
"low_estimate": 1646,
"minimum": 125,
"product_id": "2ea18da2-bcf0-4df7-a7b8-a827e9945322",
"surge_multiplier": 3.4
},
{
"currency_code": "INR",
"display_name": "uberXL",
"distance": 18.45,
"duration": 3503,
"estimate": "₹1,646-2,099",
"high_estimate": 2099,
"localized_display_name": "uberXL",
"low_estimate": 1646,
"minimum": 125,
"product_id": "a4404842-e40a-471b-a7a5-13da3551e94f",
"surge_multiplier": 3.4
}
]
}
}

现在我在按钮的 onclicklisteners 上添加了这段代码:

String uri = "uber://?client_id=eFrzgz_2Du2KYUXIi3MKaNOWtxo3i77K&action=setPickup&pickup[latitude]=37.775818&pickup[longitude]=-122.418028&pickup[nickname]=UberHQ&pickup[formatted_address]=1455%20Market%20St%2C%20San%20Francisco%2C%20CA%2094103&dropoff[latitude]=37.802374&dropoff[longitude]=-122.405818&dropoff[nickname]=Coit%20Tower&dropoff[formatted_address]=1%20Telegraph%20Hill%20Blvd%2C%20San%20Francisco%2C%20CA%2094133&product_id=a1111c8c-c720-46c3-8534-2fcdd730040d";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(uri));
startActivity(intent);


单击这些按钮时,它会重定向到具有正确 src 和 dst 的优步应用程序,但它没有选择正确的优步类别,如 UberX、UberGo、UberL 等。它始终选择默认类别。如何将其自定义为用户只需单击一个按钮即可预订出租车的级别。

最佳答案

Android 版 uber-rides-sdk 中的深度链接测试使用的 sample data 显示与您发送的 Intent 相同的参数,因此它应该可以工作。

uber:?action=setPickup&client_id=clientId&product_id=productId&pickup%5Blatitude%5D=32.1234&pickup%5Blongitude%5D=-122.3456&pickup%5Bnickname%5D=pickupNick&pickup%5Bformatted_address%5D=Pickup%20Address&dropoff%5Blatitude%5D=32.5678&dropoff%5Blongitude%5D=-122.6789&dropoff%5Bnickname%5D=pickupNick&dropoff%5Bformatted_address%5D=Dropoff%20Address

在测试数据中,我看到它们还 URL/percent encode 键和值(例如 pickup%5Blatitude%5D=32.1234),但是在 documentation 中它们没有。
尝试对数据 URI 进行编码并重试。

也许您将 Intent 发送到优步应用太晚了?即当产品id(优步车)在服务器上不存在后,优步应用也不会选择它。

这些产品是从 sandbox API 还是生产 API 端点返回的?

您能否先通过向 GET /v1/products/{product_id} 发出请求来验证产品 ID,并确保您获得 200 OK HTTP 响应状态代码和响应正文中的正确产品详细信息?

关于android - 在 Android 应用程序上集成 uber API(深度链接),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34277038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com