PHP code example of secgin / tcmb-exchange-rates

1. Go to this page and download the library: Download secgin/tcmb-exchange-rates 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/ */

    

secgin / tcmb-exchange-rates example snippets


$apiUrl = 'https://evds2.tcmb.gov.tr/service/evds/';
$apiKey = '...';

$tcmb = new Tcmb();
$tcmb->setApiInfo($apiUrl, $apiKey);

$result = $tcmb->getCurrencyRates(['USD', 'EUR', 'GBP']);

// Seçilen Tüm Kurlar
$rates = $result->getRates();

// Seçilen kurlardan sadece bir tanesini almak için
$rate = $result->getRate('USD');


$tcmb = new Tcmb();

$result = $tcmb->getCurrencyRatesByXML(['USD', 'EUR', 'GBP']);

// Seçilen Tüm Kurlar
$rates = $result->getRates();

// Seçilen kurlardan sadece bir tanesini almak için
$rate = $result->getRate('USD');