|
4 | 4 | require_once __DIR__ . '/vendor/autoload.php'; |
5 | 5 |
|
6 | 6 | try { |
7 | | - // Load the Atom feed and convert it to an array |
| 7 | + // Load the RSS feed and convert to an array |
8 | 8 | $feed = Feed::loadAtom('https://sharpapi.com/feed')->toArray(); |
9 | 9 | } catch (Exception $e) { |
10 | 10 | echo "Failed to load feed: ", $e->getMessage(); |
11 | 11 | exit(1); |
12 | 12 | } |
13 | 13 |
|
14 | | -// Check if 'entry' key exists and contains data |
15 | | -if (!isset($feed['entry']) || !is_array($feed['entry']) || empty($feed['entry'])) { |
16 | | - echo "Feed data is missing or 'entry' key is not available.\n"; |
17 | | - exit(1); |
18 | | -} |
19 | | - |
20 | | -// Generate the list of all blog posts with full description |
| 14 | +// Generate the list of blog posts |
21 | 15 | $posts = ''; |
22 | | -foreach ($feed['entry'] as $post) { |
23 | | - $date = date('d/m/Y', strtotime($post['updated'] ?? '')); |
24 | | - $title = $post['title'] ?? 'No title'; |
25 | | - $link = $post['link']['@attributes']['href'] ?? '#'; |
26 | | - $description = isset($post['summary']) ? strip_tags($post['summary']) : ''; // Remove HTML tags for cleaner text |
27 | | - |
28 | | - $posts .= sprintf( |
29 | | - "\n* **[%s]** [%s](%s \"%s\")\n > %s", |
30 | | - $date, |
31 | | - $title, |
32 | | - $link, |
33 | | - $title, |
34 | | - $description |
35 | | - ); |
| 16 | +if (isset($feed['entry']) && is_array($feed['entry'])) { |
| 17 | + foreach ($feed['entry'] as $post) { |
| 18 | + $date = date('d/m/Y', strtotime($post['updated'] ?? '')); |
| 19 | + $title = $post['title'] ?? 'Untitled'; |
| 20 | + $link = $post['link']['@attributes']['href'] ?? '#'; |
| 21 | + $description = strip_tags($post['summary'] ?? ''); // Strip HTML tags for cleaner README |
| 22 | + |
| 23 | + $posts .= sprintf( |
| 24 | + "\n* **[%s]** [%s](%s \"%s\")\n > %s", |
| 25 | + $date, |
| 26 | + $title, |
| 27 | + $link, |
| 28 | + $title, |
| 29 | + $description |
| 30 | + ); |
| 31 | + } |
36 | 32 | } |
37 | 33 |
|
38 | 34 | // Load README.md content |
|
0 commit comments