Browse Source

RSSの追加

諏訪子 1 year ago
parent
commit
aeadf533b2
1 changed files with 54 additions and 0 deletions
  1. 54 0
      www/rss.php

+ 54 - 0
www/rss.php

@@ -0,0 +1,54 @@
+<?php
+  include("../api.php");
+  include("../include/lib.php");
+  if (!isset($_GET["id"])) die("不正なID。");
+  $id = (int)$_GET["id"];
+  $res = get("user/".$id."/profile/top");
+  if (!isset($res->body) || $res->error) {
+    header("Location: /404.php");
+    die();
+  }
+  $res = $res->body;
+  $cont = [];
+  foreach ($res->illusts as $k => $v) $cont[$k] = $v;
+  foreach ($res->manga as $k => $v) $cont[$k] = $v;
+  usort($cont, function ($a, $b) {
+    return strtotime($b->createDate) - strtotime($a->createDate);
+  });
+
+  header("Content-type: application/atom+xml");
+?>
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"  xml:lang="ja-JP">
+  <link rel="self" href="<?= SITEURL ?>/users/?id=<?= $id ?>" />
+  <id><?= $id ?></id>
+  <title><?= $res->extraData->meta->ogp->title ?></title>
+  <updated>2023-04-19T00:00:00Z</updated>
+  <author><?= $res->extraData->meta->ogp->title ?></author>
+  <image>
+    <url><?= SITEURL ?>/userhead.php?id=<?= $id ?></url>
+    <title><?= $res->extraData->meta->ogp->title ?></title>
+    <link rel="self" href="<?= SITEURL ?>/users/?id=<?= $id ?>" />
+  </image>
+<?php
+  foreach ($cont as $c) {
+    $img = get("illust/".$c->id);
+?>
+  <entry>
+    <id><?= $c->id ?></id>
+    <author>
+      <name><?= $c->userName ?></name>
+      <uri><?= SITEURL."/users/?id=".$c->userId ?></url>
+    </author>
+    <published><?= $img->body->createDate ?></published>
+    <title type="html"><?= $img->body->illustTitle ?></title>
+    <link rel="alternate" href="<?= SITEURL."/artworks/?id=".$c->id ?>" />
+    <content type="html">
+      <?= $img->body->illustComment ?><br />
+<?php for ($i = 0; $i < $img->body->pageCount; $i++) { ?>
+      <?= SITEURL.imgprx(str_replace("_p0", "_p".$i, $img->body->urls->original)) ?><br />
+<?php } ?>
+    </content>
+  </entry>
+<?php } ?>
+</feed>