Compare commits

...

7 Commits

Author SHA1 Message Date
emilyd
14d1ac9305 Merge pull request 'shields.io endpoints' (#14) from shields-endpoint into main
Reviewed-on: https://git.donut.gq/emilyd/moodblog/pulls/14
2022-11-26 08:52:09 +00:00
emilyd
ad8f10649c Merge branch 'main' into shields-endpoint 2022-11-26 08:51:08 +00:00
emilyd
3299636a46 add shields tunes endpoint 2022-11-26 10:44:22 +02:00
emilyd
7985cf3c5d add shields tunes endpoint to api landing page 2022-11-26 10:43:45 +02:00
emilyd
631dcfde48 add shields mood endpoint 2022-11-26 10:40:46 +02:00
emilyd
c445b988e8 API landing page 2022-11-26 10:36:14 +02:00
emilyd
00fdce204e shields post endpoint 2022-11-26 10:36:06 +02: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";
}
?>
}