Skip to content

Instantly share code, notes, and snippets.

@sotarok
Created October 20, 2010 16:23
Show Gist options
  • Save sotarok/636741 to your computer and use it in GitHub Desktop.
Save sotarok/636741 to your computer and use it in GitHub Desktop.
<?php
/**
* <cron>
* * * * * * /usr/bin/php /path/to/reroom-rss.php >>/path/to/cron.log 2>&1
* </cron>
*/
require_once 'Net/Socket/Tiarra.php'; // openpear
$url = "http://reroom.jp/latest/feed/";
try
{
$m = new Memcached();
$m->addServer('localhost', 11211);
$tiarra = new Net_Socket_Tiarra('julius');
$x = simplexml_load_file($url);
foreach ($x->entry as $entry) {
$link = (string)$entry->id;
if (!$m->get($link)) {
if (preg_match('!(http://s.reroom.jp/.+\.jpg)!', (string)$entry->summary, $match)) {
$msg = sprintf("New: %s (by %s) %s", $entry->title, $entry->author->name, $match[1]);
echo $msg, PHP_EOL;
$tiarra->message('#info-reroom@es', $msg);
}
$m->set($link, true);
}
}
} catch (Exception $e) {
echo $e->getMessage();
// notice
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment