PHP code example of ipinchuk / php-yandex-taxi-api

1. Go to this page and download the library: Download ipinchuk/php-yandex-taxi-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ipinchuk / php-yandex-taxi-api example snippets




$clientId = 'YOUR_CLIENT_ID';
$apiKey = 'YOUR_API_KEY';
$parkId = 'YOUR_PARK_ID';

$client = new IPinchuk\YandexTaxi\Client($clientId, $apiKey, $parkId);

$cars = $client->api('cars')->all();

$cars = $client->api('drivers')->all();

$profile_id = "SOME_DRIVER_PROFILE_ID";
$car_id = "SOME_CAR_ID";

$cars = $client->api('drivers')->bindVehicle($profile_id, $car_id);

$profile_id = "SOME_DRIVER_PROFILE_ID";
$car_id = "SOME_CAR_ID";

$cars = $client->api('drivers')->unbindVehicle($profile_id, $car_id);

$cars = $client->api('rules')->all();

$cars = $client->api('orders')->all();

$cars = $client->api('transactions')->all();

$cars = $client->api('transactions')->categories();

$driver_id = 'SOME_DRIVER_ID';

$cars = $client->api('transactions')->driverTransactions($driver_id);

$order_ids = ['ORDER_ID_1', 'ORDER_ID_2', 'ORDER_ID_3'];

$cars = $client->api('transactions')->orderTransactions($order_ids);

$driver_id = 'SOME_DRIVER_ID';
$amount = '-10'; // You can increase or decrease driver balance
$cad_id = 'SOME_TRANSACTION_CATEGORY_ID';
$description = 'SOME_TRANSACTION_DESCRIPTION';

$cars = $client->api('transactions')->createTransaction($driver_id, $amount, $cad_id, $description);


$driver_id = 'SOME_DRIVER_ID';
$amount = '10';
$cad_id = 'SOME_TRANSACTION_CATEGORY_ID';
$description = 'SOME_TRANSACTION_DESCRIPTION';

// For increase balance.
$cars = $client->api('transactions')->increaseBalance($driver_id, $amount, $cad_id, $description);
// For decrease balance
$cars = $client->api('transactions')->decreaseBalance($driver_id, $amount, $cad_id, $description);

$client->setProxy('YOR_PROXY_IP');
bash
$ composer