';
$media = '';
$avatar = '';
$tootLink = '';
// Check for YouTube video link
$youtubeRegex = '/https?:\/\/(www\.)?(m\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]{11})/';
preg_match($youtubeRegex, $status['content'], $youtubeMatch);
if ($youtubeMatch) {
// Extract video ID from YouTube link
$videoId = $youtubeMatch[3];
// Create embedded player for YouTube video
$media = '';
} else {
// Check for image attachments
if (count($status['media_attachments']) > 0) {
$media = '
';
foreach ($status['media_attachments'] as $attachment) {
if ($attachment['type'] === 'image') {
$media .= ' ';
}
}
$media .= '
';
}
}
// Check for spoiler tag
if (strpos($status['url'], 'activity') !== false) {
$avatar = ' ';
$tootLink = '';
} else {
$avatar = ' ';
$tootLink = 'View on Mastodon';
}
// Get the date of the status
$date = new DateTime($status['created_at']);
// Append content to feed
echo $content . $media . $avatar . $tootLink . ' ' . $date->format('Y-m-d H:i:s') . '';
}
?>