i would like to program myself a webpage that displays some data from companies. I already found a API that displays different values, which someone could choose.
https://financialmodelingprep.com/developer/docs#Companies-Financial-Statements
So i started putting together my webpage and added an input. In that way the user could choose which company he is searching for.
<input type="text" name="Ticker" placeholder="Ticker Symbol">
Then at the end of the file i added a php part that picks that data(JSON) from the URL:
<?php
if(isset($_GET['Ticker']))
{
$Ticker_Name = $_GET['Ticker'];
echo '<p>Your choosen company is '. $Ticker_Name . '</p>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://financialmodelingprep.com /api/financials/income-statement/' . $Ticker_Name);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
}
?>
This displays the raw informations given from the api. But the problem i have is formatting/accessing the json data given from the API.
The last thing I tried is:
<?php
if(isset($_GET['Ticker']))
{
$Ticker_Name = $_GET['Ticker'];
echo '<p>Your choosen company is '. $Ticker_Name . '</p>';
$url = file_get_contents('https://financialmodelingprep.com/api/financials/income-statement/' . $Ticker_Name);
//$daten = file_get_contents($url);
$json = json_decode($url, true);
echo $json->Revenue;
}
?>
Getting this message:
Notice: Trying to get property 'Revenue' of non-object
without showing anything on data.
I would really appreciate if somebody could help me, thanks in advance.