Answer the question
In order to leave comments, you need to log in
How to use api in php?
The essence of the question is how to display certain information from the api, for example, only the dollar exchange rate here is the code:
<?php
$url = ' https://api.privatbank.ua/p24api/pubinfo?exchange&... ';
$json_response = file_get_contents($url);
$response = json_decode($json_response);
foreach ($response as $item){
var_dump($item);
}
Answer the question
In order to leave comments, you need to log in
$url = 'https://api.privatbank.ua/p24api/pubinfo?exchange&json&coursid=11';
$json_response = file_get_contents($url);
$response = json_decode($json_response,true);
$dollarcost = $response[0]['buy'];
echo $dollarcost;
In order for you to get not only the dollar rate, but namely WORK WITH API, google about curl. It's actually easier than it looks at first glance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question