PHP code example of metalpriceapi / metalpriceapi-php
1. Go to this page and download the library: Download metalpriceapi/metalpriceapi-php 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/ */
metalpriceapi / metalpriceapi-php example snippets
use MetalpriceAPI\Client;
$client = new Client('SET_YOUR_API_KEY_HERE');
$result = $client->fetchLive('USD', ['XAU', 'XAG', 'XPD', 'XPT']);
use MetalpriceAPI\Client;
// Default (US)
$client = new Client('SET_YOUR_API_KEY_HERE');
// Europe
$client = new Client('SET_YOUR_API_KEY_HERE', Client::BASE_URL_EU);
$client = new Client('SET_YOUR_API_KEY_HERE');
// Switch to EU server
$client->setServer('eu');
// Switch back to US server
$client->setServer('us');