ryocomments/index.php

42 行
1.3 KiB
PHP

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
if (isset($_GET['status']) && $_GET['status'] != '') {
$stat = htmlspecialchars($_GET['status']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://social.076.ne.jp/api/v1/statuses/'.$stat.'/context');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$get = curl_exec($ch);
curl_close($ch);
$comment = json_decode($get)->descendants;
?>
<div class="comment-head">Comments (<?php echo count($comment); ?>)</div>
<?php
foreach ($comment as $c) {
?>
<hr />
<div class="comment-meta">
<span class="comment-icon"><img style="max-width: 25px; max-height: 25px;" src="<?php echo $c->account->avatar_static; ?>" alt="<?php echo $c->account->display_name ?>'s icon" /></span>
<span class="comment-auth"><a href="<?php echo $c->account->url; ?>"><?php echo $c->account->display_name; ?> (<?php echo $c->account->fqn ?>)</a></span>
<div class="comment-date"><?php echo date('Y/m/d, H:i:s', strtotime($c->created_at)); ?></div>
</div>
<div class="comment-body">
<?php echo $c->content; ?>
</div>
<?php
}
}
?>
</body>
</html>