Example #1
0
        function testData_XML_OPML_OPMLParser() 
        {
			$OPMLParser = new OPMLParser("http://share.opml.org/opml/top100.opml");
			//$OPMLParser = new OPMLParser("http://192.168.1.254:9059/test.opml");
			
			$feeds = $OPMLParser->Parse();
			
			$this->assertTrue(($feeds && count($feeds) > 0), "OPML successfully parsed. Feeds returned");
        }
Example #2
0
OCP\JSON::callCheck();
session_write_close();
$l = OC_L10N::get('news');
function bailOut($msg)
{
    OCP\JSON::error(array('data' => array('message' => $msg)));
    OCP\Util::writeLog('news', 'ajax/importopml.php: ' . $msg, OCP\Util::ERROR);
    exit;
}
if (!isset($_POST['path'])) {
    bailOut($l->t('No file path was submitted.'));
}
require_once 'news/opmlparser.php';
$raw = file_get_contents($_POST['path']);
try {
    $parsed = OPMLParser::parse($raw);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
if ($parsed == null) {
    bailOut($l->t('An error occurred while parsing the file.'));
}
$data = $parsed->getData();
function importFeed($feedurl, $folderid)
{
    $feedmapper = new OCA\News\FeedMapper();
    $feedid = $feedmapper->findIdFromUrl($feedurl);
    $l = OC_L10N::get('news');
    if ($feedid === null) {
        $feed = OCA\News\Utils::slimFetch($feedurl);
        if ($feed !== null) {