Son aktivite 2 months ago

友链状态检测 flink_count.json 适配

Joe

qxzhan's Avatar qxzhan bu gisti düzenledi 2 months ago. Düzenlemeye git

1 file changed, 35 insertions

php(dosya oluşturuldu)

@@ -0,0 +1,35 @@
1 + <?php
2 + require_once dirname(__FILE__) . '/../config.inc.php';
3 + $db = \Typecho\Db::get();
4 + try {
5 + $query = $db->select('title', 'url', 'logo', 'description')
6 + ->from('table.friends')
7 + ->where('status = ?', 1);
8 + $rows = $db->fetchAll($query);
9 + $link_list = [];
10 + foreach ($rows as $row) {
11 + $name = $row['title'];
12 + $link = $row['url'];
13 + $avatar = $row['logo'] ?? '';
14 + $descr = $row['description'];
15 + $siteshot = "https://v2.xxapi.cn/api/screenshot?url=" . urlencode($link) . "&return=302";
16 +
17 + $link_list[] = [
18 + "name" => $name,
19 + "link" => $link,
20 + "avatar" => $avatar,
21 + "descr" => $descr,
22 + "siteshot" => $siteshot
23 + ];
24 + }
25 + $length = count($link_list);
26 + $output = [
27 + "link_list" => $link_list,
28 + "length" => $length
29 + ];
30 + header('Content-Type: application/json; charset=utf-8');
31 + echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
32 + } catch (\Typecho\Db\Exception $e) {
33 + header('Content-Type: application/json; charset=utf-8');
34 + echo json_encode(['error' => $e->getMessage()], JSON_UNESCAPED_UNICODE);
35 + }
Daha yeni Daha eski