We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`<?php $apiKey = 'API Key';
function callStockdataAPI($symbol, $apiKey) { $endpoint = 'https://www.alphavantage.co/query'; $params = [ 'function' => 'TIME_SERIES_DAILY_ADJUSTED', 'symbol' => $symbol, 'apikey' => $apiKey ];
$url = $endpoint . '?' . http_build_query($params); try { $response = file_get_contents($url); if ($response === false) { return "API call failed for {$symbol}"; } $data = json_decode($response, true); if (json_last_error() !== JSON_ERROR_NONE) { return "JSON decoding error for {$symbol}"; } if (!isset($data['Time Series (Daily)'])) { return "No data available for {$symbol}"; } $latestData = reset($data['Time Series (Daily)']); $stockPrice = $latestData['5. adjusted close']; return "{$symbol}: \${$stockPrice}"; } catch (\Throwable $e) { return "Error fetching stock price for {$symbol}: " . $e->getMessage(); }
}
function callCryptodataAPI($symbol, $apiKey) { $endpoint = 'https://www.alphavantage.co/query'; $params = [ 'function' => 'DIGITAL_CURRENCY_DAILY', 'symbol' => $symbol, 'market' => 'USD', 'apikey' => $apiKey ];
$url = $endpoint . '?' . http_build_query($params); try { $response = file_get_contents($url); if ($response === false) { return "API call failed for {$symbol}"; } $data = json_decode($response, true); if (json_last_error() !== JSON_ERROR_NONE) { return "JSON decoding error for {$symbol}"; } if (!isset($data['Time Series (Digital Currency Daily)'])) { return "No data available for {$symbol}"; } $latestData = reset($data['Time Series (Digital Currency Daily)']); $price = $latestData['4a. close (USD)']; return "{$symbol}: \${$price}"; } catch (\Throwable $e) { return "Error fetching cryptocurrency data for {$symbol}: " . $e->getMessage(); }
$data = []; $symbols = [ 'GOOG', 'AAPL', 'TSLA', 'META', 'AMZN', 'NFLX', 'GME', 'AMC', 'NOK', 'TSM', 'BLK', 'BTC', 'ETH', 'XRP' ];
foreach ($symbols as $symbol) { if (strpos($symbol, 'BTC') !== false || strpos($symbol, 'ETH') !== false || strpos($symbol, 'XRP') !== false) { $data[] = callCryptodataAPI($symbol, $apiKey); } else { $data[] = callStockdataAPI($symbol, $apiKey); } }
if (!empty($data)) { $stockTickerText = implode(" ", $data); } else { $stockTickerText = "No data available"; } ?>
.ticker span { display: inline-block; padding-left: 100%; animation: marquee 20s linear infinite; } @keyframes marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } } </style>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`<?php
$apiKey = 'API Key';
function callStockdataAPI($symbol, $apiKey)
{
$endpoint = 'https://www.alphavantage.co/query';
$params = [
'function' => 'TIME_SERIES_DAILY_ADJUSTED',
'symbol' => $symbol,
'apikey' => $apiKey
];
}
function callCryptodataAPI($symbol, $apiKey)
{
$endpoint = 'https://www.alphavantage.co/query';
$params = [
'function' => 'DIGITAL_CURRENCY_DAILY',
'symbol' => $symbol,
'market' => 'USD',
'apikey' => $apiKey
];
}
$data = [];
$symbols = [
'GOOG', 'AAPL', 'TSLA', 'META', 'AMZN', 'NFLX', 'GME', 'AMC', 'NOK', 'TSM', 'BLK',
'BTC', 'ETH', 'XRP'
];
foreach ($symbols as $symbol) {
if (strpos($symbol, 'BTC') !== false || strpos($symbol, 'ETH') !== false || strpos($symbol, 'XRP') !== false) {
$data[] = callCryptodataAPI($symbol, $apiKey);
} else {
$data[] = callStockdataAPI($symbol, $apiKey);
}
}
if (!empty($data)) {
<style> /* CSS for the ticker marquee */ .ticker { background-color: black; color: lime; font-family: "Courier New", monospace; font-size: 16px; overflow: hidden; white-space: nowrap; }$stockTickerText = implode(" ", $data);
} else {
$stockTickerText = "No data available";
}
?>
The text was updated successfully, but these errors were encountered: