Skip to content

Instantly share code, notes, and snippets.

@kimondo
Created February 10, 2015 15:47
Show Gist options
  • Save kimondo/42c39f9cc6d6f9c18b2d to your computer and use it in GitHub Desktop.
Save kimondo/42c39f9cc6d6f9c18b2d to your computer and use it in GitHub Desktop.
EduBoard RSS ticker
<?php
$rss = new DOMDocument();
#feed info here
$rss->load('http://feeds.bbci.co.uk/news/rss.xml');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
#I'm just using the title
#'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
#'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
#'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
#number of items to show in the feed
$limit = 6;
for($x=0;$x<$limit;$x++) {
$title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
echo '<strong>'.$title.'</strong> - ';
$message = $message . $title." * ";
}
#send it to the Eduboard
exec('sudo kill $(ps aux | grep \'[p]ython.*examples.*.py\' | awk \'{print $2}\')');
exec('sudo python /home/pi/Adafruit_Python_SSD1306/examples/reset.py');
@unlink("reset.dat");
exec('sudo python /home/pi/Adafruit_Python_SSD1306/examples/text.py "'.$message.'" > /dev/null &');
exec('sudo python /home/pi/Adafruit_Python_SSD1306/examples/led.py "1" > /dev/null &');
echo '<html><h1>Message sent!</h1><h2>'.$message.'</h2></html>';break;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment