352-uber 中文文档教程
uber-api
Uber API 的 NodeJS 实现。 最新更新已实施承诺模式。
Installation
npm install uber-api
Usage
var Uber = require('uber-api')({server_token:'YOUR SERVER TOKEN',version:'v1'}),
lat = 36,
lon = -94;
Uber.getProducts(lat, lon, function(error, response) {
if (error) {
console.log(error);
} else {
console.log(response);
}
});
Uber.getProducts(lat, lon).then(function(response){
console.log(response);
}, function(error){
console.error(response);
});
API Reference
getProducts(latitude, longitude[, callback])
getPriceEstimate(start_latitude, start_longitude, end_latitude, end_longitude[, callback])
getTimeEstimate(start_latitude, start_longitude [,customer_uuid] [,product_id][, callback])
getPromotions(start_latitude, start_longitued, end_latitude, end_longitued [, callback])
+getMe([callback])
+†getHistory([callback])
+这些需要您可以通过 OAuth2 获得的特殊令牌。 然后,您可以使用 {bearer_token:'YOUR BEARER TOKEN',version:'v1'} 初始化 Uber。
† 此功能检查传入的版本,如果是“v1”,将自动调整为“v1.1”。 根据 Uber 文档 (https://developer.uber.com/v1/endpoints/#user-activity-v1) v1 需要特殊许可才能使用。 该库当前假定此权限不存在。
速率限制状态作为响应对象的成员返回。
Uber.getProducts(lat, lon).then(function(response){
console.log(response.rate_limit);
});
uber-api
NodeJS implementation of Uber API. The latest update has promise pattern implemented.
Installation
npm install uber-api
Usage
var Uber = require('uber-api')({server_token:'YOUR SERVER TOKEN',version:'v1'}),
lat = 36,
lon = -94;
Uber.getProducts(lat, lon, function(error, response) {
if (error) {
console.log(error);
} else {
console.log(response);
}
});
Uber.getProducts(lat, lon).then(function(response){
console.log(response);
}, function(error){
console.error(response);
});
API Reference
getProducts(latitude, longitude[, callback])
getPriceEstimate(start_latitude, start_longitude, end_latitude, end_longitude[, callback])
getTimeEstimate(start_latitude, start_longitude [,customer_uuid] [,product_id][, callback])
getPromotions(start_latitude, start_longitued, end_latitude, end_longitued [, callback])
+getMe([callback])
+†getHistory([callback])
+These require special tokens you can get via OAuth2. You can then initialize Uber with {bearer_token:'YOUR BEARER TOKEN',version:'v1'}.
† This functionality inspects the version passed in and if it is "v1" will auto adjust to "v1.1". As per the Uber documentation (https://developer.uber.com/v1/endpoints/#user-activity-v1) v1 requires special permission to use. This library currently assumes this permission is not in place.
Rate limit state is returned as a member of the response object.
Uber.getProducts(lat, lon).then(function(response){
console.log(response.rate_limit);
});