', '', $content); $feed = new SimpleXMLElement($content); /* KABOOM */ foreach($feed->channel->item as $item) { $timestamp = strtotime($item->pubDate); if ($timestamp > $latestGetTime) { echo 'Now publishing: ' . $item->title . "\n"; /* Send to Telegram Channel */ if (DEBUG) echo 'Publishing on Telegram channel...'; $message = $item->title . "\n\n" . $item->description . "\n" . $item->link; $r = file_get_contents(API_URL . API_TOKEN . '/sendMessage?chat_id=' . urlencode(API_CHANNEL_ID) . '&text=' . urlencode($message)); echo ($r ? 'done' : 'error') . "\n"; /* Send to Email/Mailing List */ if (DEBUG) echo 'Sending to email address...'; $title = mb_convert_encoding($item->title, 'ASCII'); $text = mb_convert_encoding($item->description, 'UTF-8') . "\n" . $item->link; $r = mail(MAIL_TO_ADDR, $title, $text, 'From: ' . MAIL_FROM_ADDR . "\n" . 'Content-Type: text/plain; charset=UTF-8'); echo ($r ? 'done' : 'error') . "\n"; echo "\n"; } } file_put_contents('latestFeedTimestamp.conf', $newLatestGetTime ); /* ===== END of MAIN PROGRAM ===== */ ?>