PHP code example of icekristal / xecdapi-for-laravel

1. Go to this page and download the library: Download icekristal/xecdapi-for-laravel 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/ */

    

icekristal / xecdapi-for-laravel example snippets


composer 

    'xecdapi' => [
        'auth' => [
            'username' => env('XECD_USERNAME'),
            'password' => env('XECD_PASSWORD'),
        ],
        'base_url' => env('XECD_URL', 'https://xecdapi.xe.com'),
    ],

php artisan vendor:publish --provider="Icekristal\XecdapiForLaravel\XecdapiServiceProvider" --tag="config"

use Icekristal\XecdapiForLaravel\Facades;

Xecdapi::getAccountInfo();

$needParams = [
    'from' => 'USD', //example
    'to' => 'EUR', //example
    'amount' => 1, //example
];

Xecdapi::setQueryParams($needParams)->getCurrencies();
Xecdapi::setQueryParams($needParams)->convertFrom();
Xecdapi::setQueryParams($needParams)->convertTo();
Xecdapi::setQueryParams($needParams)->centralBankExchangeRate();

//custom convert one to one
Xecdapi::fastConvertFiat(string $from, string $to, float|int $amount = 1); //return float; if -1 then error