shields.io endpoints #14

Merged
emilyd merged 6 commits from shields-endpoint into main 2022-11-26 08:52:09 +00:00
4 changed files with 68 additions and 0 deletions

14
api/index.php Normal file
View File

@ -0,0 +1,14 @@
<?php include('../templates/header.php'); ?>
<div class='window'>
<div class='window-bar'>
<span>moodblog API</span>
</div>
<div class='window-content'>
<ul>
<li><a href="shields-posts.php">shields.io posts endpoint</a></li>
<li><a href="shields-mood.php">shields.io mood endpoint</a></li>
<li><a href="shields-tunes.php">shields.io tunes endpoint</a></li>
</ul>
</div>
</div>
<?php include('../templates/footer.php'); ?>

18
api/shields-mood.php Normal file
View File

@ -0,0 +1,18 @@
<?php
header('Content-Type: application/json');
require "../templates/config.php";
?>
{
"schemaVersion": 1,
"label": "current mood",
"color": "lightgrey",
<?php
require "../creds.php";
$result = mysqli_query($mysqli, "SELECT Mood FROM articles ORDER BY ID DESC LIMIT 1");
while($res = mysqli_fetch_array($result)) {
echo ' "message": "'.$res['Mood'].'"',"\n";
}
?>
}

18
api/shields-posts.php Normal file
View File

@ -0,0 +1,18 @@
<?php
header('Content-Type: application/json');
require "../templates/config.php";
?>
{
"schemaVersion": 1,
"label": "blog posts",
"color": "lightgrey",
<?php
require "../creds.php";
$result = mysqli_query($mysqli, "SELECT COUNT(ID) FROM articles");
while($res = mysqli_fetch_array($result)) {
echo ' "message": "'.$res['COUNT(ID)'].'"',"\n";
}
?>
}

18
api/shields-tunes.php Normal file
View File

@ -0,0 +1,18 @@
<?php
header('Content-Type: application/json');
require "../templates/config.php";
?>
{
"schemaVersion": 1,
"label": "current tunes",
"color": "lightgrey",
<?php
require "../creds.php";
$result = mysqli_query($mysqli, "SELECT Song FROM articles ORDER BY ID DESC LIMIT 1");
while($res = mysqli_fetch_array($result)) {
echo ' "message": "'.$res['Song'].'"',"\n";
}
?>
}