|
4 | 4 | require_once __DIR__ . '/vendor/autoload.php';
|
5 | 5 |
|
6 | 6 | try {
|
7 |
| - // Load the RSS feed and convert it to an array |
| 7 | + // Load the Atom feed and convert it 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 |
| -// Generate the list of all blog posts with full title and description |
| 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 |
15 | 21 | $posts = '';
|
16 |
| -foreach ($feed['item'] as $post) { |
17 |
| - $date = date('d/m/Y', strtotime($post['pubDate'])); |
18 |
| - $title = $post['title']; |
19 |
| - $link = $post['link']; |
20 |
| - $description = strip_tags($post['description']); // Remove any HTML tags from description |
| 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 |
21 | 27 |
|
22 | 28 | $posts .= sprintf(
|
23 | 29 | "\n* **[%s]** [%s](%s \"%s\")\n > %s",
|
|
49 | 55 | // Write the updated content to README.md
|
50 | 56 | file_put_contents($readmePath, $newContent);
|
51 | 57 |
|
52 |
| -echo "README.md updated successfully with the latest blog posts.\n"; |
| 58 | +echo "README.md updated successfully with all blog posts.\n"; |
0 commit comments