require_once INSTALLDIR.'/scripts/commandline.inc';
-if (empty($args[0]) || !Validate::uri($args[0])) {
+$validate = new Validate();
+
+if (empty($args[0]) || !$validate->uri($args[0])) {
print "$helptext";
exit(1);
}
$count = have_option('count') ? intval(get_option_value('count')) : 0;
-$sub = FeedSub::staticGet('topic', $feedurl);
+$sub = FeedSub::getKV('uri', $feedurl);
if (!$sub) {
print "Feed $feedurl is not subscribed.\n";
exit(1);
}
-$xml = file_get_contents($feedurl);
-if ($xml === false) {
- print "Bad fetch.\n";
+// Fetch the URL
+try {
+ $xml = HTTPClient::quickGet($feedurl, 'text/html,application/xhtml+xml');
+} catch (Exception $e) {
+ echo sprintf("Could not fetch feedurl %s (%d).\n", $e->getMessage(), $e->getCode());
exit(1);
}
}
}
+echo "Calling event StartFeedSubReceive\n";
Event::handle('StartFeedSubReceive', array($sub, $feed));