PHP grab json exchange rate value from API response
I am using javascript API for jQuery to get realtime currency conversion value. Does anyone know how I can get the value "result"
and value "quote"
from the API response below using PHP?
I'm new to PHP and I'm wondering if it is possible to store it in a variable.
This is JSON:
{
"success":true,
"terms":"https:\/\/currencylayer.com\/terms",
"privacy":"https:\/\/currencylayer.com\/privacy",
"query":{
"from":"CAD",
"to":"GBP",
"amount":234
},
"info":{
"timestamp":1432829168,
"quote":0.524191
},
"result":122.660694
}
I played with file_get_contents("URL")
, but I didn't understand how to get one value.
The request url looks like this:
https://apilayer.net/api/convert?access_key=...&from=CAD&to=GBP&amount=234
Thanks for the help!
+3
source to share