uber php 2021
1.0.0
透過作曲家
$ composer require stevenmaguire/uber-php
$ client = new Stevenmaguire Uber Client ( array (
' access_token ' => ' YOUR ACCESS TOKEN ' ,
' server_token ' => ' YOUR SERVER TOKEN ' ,
' use_sandbox ' => true , // optional , default false
' version ' => ' v1.2 ' , // optional , default 'v1.2'
' locale ' => ' en_US ' , // optional , default 'en_US'
));
$ products = $ client -> getProducts ( array (
' latitude ' => ' 41.85582993 ' ,
' longitude ' => ' -87.62730337 '
));
$ product = $ client -> getProduct ( $ productId );
$ estimates = $ client -> getPriceEstimates ( array (
' start_latitude ' => ' 41.85582993 ' ,
' start_longitude ' => ' -87.62730337 ' ,
' end_latitude ' => ' 41.87499492 ' ,
' end_longitude ' => ' -87.67126465 '
));
$ estimates = $ client -> getTimeEstimates ( array (
' start_latitude ' => ' 41.85582993 ' ,
' start_longitude ' => ' -87.62730337 '
));
$ promotions = $ client -> getPromotions ( array (
' start_latitude ' => ' 41.85582993 ' ,
' start_longitude ' => ' -87.62730337 ' ,
' end_latitude ' => ' 41.87499492 ' ,
' end_longitude ' => ' -87.67126465 '
));
此功能僅從1.1
版本開始可用。
$ client -> setVersion ( ' v1.2 ' ); // or v1 .1
$ history = $ client -> getHistory ( array (
' limit ' => 50 , // optional
' offset ' => 0 // optional
));
$ profile = $ client -> getProfile ();
$ attributes = array ( ' applied_promotion_codes ' => ' PROMO_CODE ' );
$ profileResponse = $ client -> setProfile ( $ attributes );
$ paymentMethods = $ client -> getPaymentMethods ();
$ placeId = ' home ' ;
$ place = $ client -> getPlace ( $ placeId );
$ placeId = ' home ' ;
$ attributes = array ( ' address ' => ' 685 Market St, San Francisco, CA 94103, USA ' );
$ place = $ client -> setPlace ( $ placeId , $ attributes );
$ request = $ client -> requestRide ( array (
' start_latitude ' => ' 41.85582993 ' ,
' start_longitude ' => ' -87.62730337 ' ,
' end_latitude ' => ' 41.87499492 ' ,
' end_longitude ' => ' -87.67126465 ' ,
' product_id ' => ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 ' , // Optional
' surge_confirmation_id ' => ' e100a670 ' , // Optional
' payment_method_id ' => ' a1111c8c-c720-46c3-8534-2fcd ' // Optional
));
try {
$ 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 '
));
} catch ( Stevenmaguire Uber Exception $ e ) {
$ body = $ e -> getBody ();
$ surgeConfirmationId = $ body [ ' meta ' ][ ' surge_confirmation ' ][ ' surge_confirmation_id ' ];
}
$ request = $ client -> getCurrentRequest ();
$ request = $ client -> getRequest ( $ requestId );
$ requestDetails = array (
' end_address ' => ' 685 Market St, San Francisco, CA 94103, USA ' ,
' end_nickname ' => ' da crib ' ,
' end_place_id ' => ' home ' ,
' end_latitude ' => ' 41.87499492 ' ,
' end_longitude ' => ' -87.67126465 '
);
$ updateRequest = $ client -> setCurrentRequest ( $ requestDetails );
$ requestId = ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 '
$ requestDetails = array (
' end_address ' => ' 685 Market St, San Francisco, CA 94103, USA ' ,
' end_nickname ' => ' da crib ' ,
' end_place_id ' => ' home ' ,
' end_latitude ' => ' 41.87499492 ' ,
' end_longitude ' => ' -87.67126465 '
);
$ updateRequest = $ client -> setRequest ( $ requestId , $ requestDetails );
$ requestEstimate = $ client -> getRequestEstimate ( array (
' product_id ' => ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 ' ,
' start_latitude ' => ' 41.85582993 ' ,
' start_longitude ' => ' -87.62730337 ' ,
' end_latitude ' => ' 41.87499492 ' , // optional
' end_longitude ' => ' -87.67126465 ' , // optional
));
$ map = $ client -> getRequestMap ( $ requestId );
$ receipt = $ client -> getRequestReceipt ( $ requestId );
$ request = $ client -> cancelCurrentRequest ();
$ request = $ client -> cancelRequest ( $ requestId );
$ attributes = array (
' reminder_time ' => ' 1429294463 ' ,
' phone_number ' => ' 555-555-5555 ' ,
' event ' => array (
' time ' => ' 1429294463 ' ,
' name ' => ' Frisbee with friends ' ,
' location ' => ' Dolores Park ' ,
' latitude ' => ' 37.759773 ' ,
' longitude ' => ' -122.427063 ' ,
),
' product_id ' => ' a1111c8c-c720-46c3-8534-2fcdd730040d ' ,
' trip_branding ' => array (
' link_text ' => ' View team roster ' ,
' partner_deeplink ' => ' partner://team/9383 ' ,
)
);
$ reminder = $ client -> createReminder ( $ attributes );
$ reminderId = ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 ' ;
$ reminder = $ client -> getReminder ( $ reminderId );
$ reminderId = ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 ' ;
$ attributes = array (
' reminder_time ' => ' 1429294463 ' ,
' phone_number ' => ' 555-555-5555 ' ,
' event ' => array (
' time ' => ' 1429294463 ' ,
' name ' => ' Frisbee with friends ' ,
' location ' => ' Dolores Park ' ,
' latitude ' => ' 37.759773 ' ,
' longitude ' => ' -122.427063 ' ,
),
' product_id ' => ' a1111c8c-c720-46c3-8534-2fcdd730040d ' ,
' trip_branding ' => array (
' link_text ' => ' View team roster ' ,
' partner_deeplink ' => ' partner://team/9383 ' ,
)
);
$ reminder = $ client -> setReminder ( $ reminderId , $ attributes );
$ reminderId = ' 4bfc6c57-98c0-424f-a72e-c1e2a1d49939 ' ;
$ reminder = $ client -> cancelReminder ( $ reminderId );
$ profile = $ client -> getDriverProfile ();
$ profile = $ client -> getDriverPayments ( array (
' limit ' => 50 , // optional
' offset ' => 0 // optional
));
$ profile = $ client -> getDriverTrips ( array (
' limit ' => 50 , // optional
' offset ' => 0 // optional
));
$ product = $ client -> getProduct ( $ productId );
$ rateLimit = $ client -> getRateLimit ();
$ rateLimit -> getLimit (); // Rate limit capacity per period
$ rateLimit -> getRemaining (); // Requests remaining in current period
$ rateLimit -> getReset (); // Timestamp in UTC time when the next period will begin
$ 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 '
));
$ updateRequest = $ client -> setSandboxRequest ( $ request -> request_id , array ( ' status ' => ' accepted ' ));
$ product = $ client -> getProduct ( $ productId );
$ updateProduct = $ client -> setSandboxProduct ( $ productId , array ( ' surge_multiplier ' => 2.2 , ' drivers_available ' => false ));
$ ./vendor/bin/phpunit