/** * Autodiscovers a feed url from a given url, to be used by the formslibs * filter function * * Uses simplepie with autodiscovery set to maximum level to try and find * a feed to subscribe to. * See: http://simplepie.org/wiki/reference/simplepie/set_autodiscovery_level * * @param string URL to autodiscover a url * @return string URL of feed or original url if none found */ public static function autodiscover_feed_url($url) { $rss = new moodle_simplepie(); $rss->set_feed_url($url); $rss->set_autodiscovery_level(SIMPLEPIE_LOCATOR_ALL); // When autodiscovering an RSS feed, simplepie will try lots of // rss links on a page, so set the timeout high $rss->set_timeout(20); $rss->init(); if ($rss->error()) { return $url; } return $rss->subscribe_url(); }