为了测试我制作的网址是否正确,我将它们放入浏览器中以查看是否可以获得结果。
首先,我尝试GET /v1/products
应该返回所有类型的汽车,我将它放在浏览器中,如下所示:
https://api.uber.com/v1/products?server_token=MY_TOKEN&latitude=39.914286&longitude=116.461745
哪种方法很好,并为我提供了大量的JSON产品:
{"products":[{"capacity":4,"product_id":"0ed2dbad-c769-41f5-b66d-0767da627f9e","price_details":{"service_fees":[],"cost_per_minute":0.25,"distance_unit":"km","minimum":10.0,"cost_per_distance":1.5,"base":0.001,"cancellation_fee":8.0,"currency_code":"CNY"},"image":"http:\/\/static.uberx.net.cn\/car-types\/mono\/mono-peoplesuber2.png","short_description":"People's Uber +","display_name":"People\u2019s Uber +","description":"People's Uber +"},{"capacity":4,"product_id":"6bf8dc3b-c8b0-4f37-9b61-579e64016f7a","price_details":{"service_fees":[],"cost_per_minute":0.25,"distance_unit":"km","minimum":10.0,"cost_per_distance":1.5,"base":0.001,"cancellation_fee":8.0,"currency_code":"CNY"},"image":"http:\/\/static.uberx.net.cn\/car-types\/mono\/mono-peoplesuber2.png","short_description":"People's Uber","display_name":"People's Uber","description":"People's Uber"},{"capacity":4,"product_id":"93a40036-2670-4a41-bc59-1e901ca33632","price_details":{"service_fees":[],"cost_per_minute":0.4,"distance_unit":"km","minimum":20.0,"cost_per_distance":2.3,"base":15.0,"cancellation_fee":15.0,"currency_code":"CNY"},"image":"http:\/\/static.uberx.net.cn\/car-types\/mono\/mono-china-uberx.png","short_description":"uberX","display_name":"uberX","description":"The low-cost Uber"},{"capacity":4,"product_id":"259df3b5-e062-4b2b-ab81-3e3fbba4b423","price_details":{"service_fees":[],"cost_per_minute":0.7,"distance_unit":"km","minimum":30.0,"cost_per_distance":3.85,"base":18.0,"cancellation_fee":20.0,"currency_code":"CNY"},"image":"http:\/\/d1a3f4spazzrp4.cloudfront.net\/car-types\/mono\/mono-black.png","short_description":"UberBLACK","display_name":"UberBLACK","description":"The original Uber"},{"capacity":4,"product_id":"d1b0005e-8e33-44f1-b1e5-b3f98138642a","price_details":{"service_fees":[],"cost_per_minute":0.25,"distance_unit":"km","minimum":10.0,"cost_per_distance":1.5,"base":0.001,"cancellation_fee":8.0,"currency_code":"CNY"},"image":"http:\/\/d1a3f4spazzrp4.cloudfront.net\/car-types\/mono\/mono-electric.png","short_description":"Electric Vehicles","display_name":"a","description":"a"}]}
然后,我尝试GET /v1/estimates/time
,使用相同的COORDINATES 和 SAME SERVER TOEKN ,我做了这样的网址:
https://api.uber.com/v1/estimates/time?server_token=MY_TOKEN&start_latitude=39.914286&start_longitude=116.461745
但它返回:
{"message":"No authentication provided.","code":"unauthorized"}
如果令牌已过期,它不应与实际工作正常的Products
API一起使用,因此我不认为这是问题所在。请帮助,谢谢。
顺便说一下,我正在中国测试Uber API,以防该位置可能影响此处的结果。
答案 0 :(得分:2)
GET /v1/estimates/time
端点具有区域依赖性,这可能是它不适用于中国位置的原因。在China Developer仪表板上创建应用程序后尝试一下:https://developer.uber.com.cn/并将该服务器令牌与api.uber.com.cn
一起使用。
可在此处找到相关文档:https://developer.uber.com/docs/china