Last active
July 24, 2022 16:33
-
-
Save StevenTso/b340fac0718252071e91017d7c53102e to your computer and use it in GitHub Desktop.
How to fetch Live Real-Time Gold and Silver Rates with API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- https://metalpriceapi.com/ --> | |
<?php | |
$curl = curl_init(); | |
// metalpriceapi.com | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => 'https://api.metalpriceapi.com/v1/latest?api_key=REPLACE_ME&base=USD¤cies=XAU,XAG,EUR', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => '', | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 0, | |
CURLOPT_FOLLOWLOCATION => true, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => 'GET', | |
)); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
echo $response; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment