A PHP client for authenticating with Uber using OAuth 2.0 and consuming the API.
This package is intended to be used for communicating with the Uber API after you've secured an access token from your users. To authenticate users and retrieve access tokens, use stevenmaguire/oauth2-uber.
Via Composer
$ composer require stevenmaguire/uber-php
or update your composer.json
file to include:
"require": {
"stevenmaguire/uber-php": "~1.0"
}
Run composer update
$client = new Stevenmaguire\Uber\Client(array(
'access_token' => 'YOUR ACCESS TOKEN',
'server_token' => 'YOUR SERVER TOKEN',
'use_sandbox' => true, // optional, default false
'version' => 'v1', // optional, default 'v1'
'locale' => 'en_US', // optional, default 'en_US'
));
Please review the Sandbox documentation on how to develop and test against these endpoints without making real-world Requests and being charged.
By location:
$products = $client->getProducts(array(
'latitude' => '41.85582993',
'longitude' => '-87.62730337'
));
By Id:
$product = $client->getProduct($product_id);
https://developer.uber.com/v1/endpoints/#product-types
$estimates = $client->getPriceEstimates(array(
'start_latitude' => '41.85582993',
'start_longitude' => '-87.62730337',
'end_latitude' => '41.87499492',
'end_longitude' => '-87.67126465'
));
https://developer.uber.com/v1/endpoints/#price-estimates
$estimates = $client->getTimeEstimates(array(
'start_latitude' => '41.85582993',
'start_longitude' => '-87.62730337'
));
https://developer.uber.com/v1/endpoints/#time-estimates
$promotions = $client->getPromotions(array(
'start_latitude' => '41.85582993',
'start_longitude' => '-87.62730337',
'end_latitude' => '41.87499492',
'end_longitude' => '-87.67126465'
));
https://developer.uber.com/v1/endpoints/#promotions
This feature is only available in version 1.1
.
$client->setVersion('v1.1');
$history = $client->getHistory(array(
'limit' => 50, // optional
'offset' => 0 // optional
));
https://developer.uber.com/v1/endpoints/#user-activity-v1-1
$profile = $client->getProfile();
https://developer.uber.com/v1/endpoints/#user-profile
$request = $client->requestRide(array(
'product_id' => '4bfc6c57-98c0-424f-a72e-c1e2a1d49939',
'start_latitude' => '41.85582993',
'start_longitude' => '-87.62730337',
'end_latitude' => '41.87499492',
'end_longitude' => '-87.67126465'
));
https://developer.uber.com/v1/endpoints/#request
$request = $client->getRequest($request_id);
https://developer.uber.com/v1/endpoints/#request-details
$map = $client->getRequestMap($request_id);
https://developer.uber.com/v1/endpoints/#request-map
$request = $client->cancelRequest($request_id);
https://developer.uber.com/v1/endpoints/#request-cancel
Rate limiting is implemented on the basis of a specific client's secret token. By default, 1,000 requests per hour can be made per secret token.
When consuming the service with this package, your rate limit status will be made available within the client.
$product = $client->getProduct($product_id);
$rate_limit = $client->getRateLimit();
$rate_limit->getLimit(); // Rate limit capacity per period
$rate_limit->getRemaining(); // Requests remaining in current period
$rate_limit->getReset(); // Timestamp in UTC time when the next period will begin
These values will update after each request. getRateLimit
will return null after the client is created and before the first successful request.
https://developer.uber.com/v1/api-reference/#rate-limiting
$ ./vendor/bin/phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.