I don’t know how to insert this API data in database.
This is my API:
https://api.metalpriceapi.com/v1/latest?api_key=cb15852705e671c76a4dc1ac9789ed2a&base=USD¤cies=XAU,XAG,EUR
This is my code to get/check API data and it is working fine:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.metalpriceapi.com/v1/latest?api_key=cb15852705e671c76a4dc1ac9789ed2a&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;
?>
I was trying to fetch data from this API and want to store this API data in MySQL database in localhost. Basically this is metal price API which shows the rates of metal. I want to store these metal rates in MySQL database in localhost.
4