当前位置: 首页>>代码示例>>PHP>>正文


PHP Feed::loadRss方法代码示例

本文整理汇总了PHP中Feed::loadRss方法的典型用法代码示例。如果您正苦于以下问题:PHP Feed::loadRss方法的具体用法?PHP Feed::loadRss怎么用?PHP Feed::loadRss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Feed的用法示例。


在下文中一共展示了Feed::loadRss方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * 运行
  */
 function run()
 {
     $rss = \Feed::loadRss($this->rssUrl);
     $data = ['title' => $rss->title, 'description' => $rss->description, 'link' => $rss->link, 'items' => $rss->item, 'articles' => $this->parseItems($rss->item)];
     $this->dataObject = (object) $data;
     return $this;
 }
开发者ID:slince,项目名称:rss-collector,代码行数:10,代码来源:RssCollector.php

示例2: getFeed

 public function getFeed($options)
 {
     if (empty($options['sa_vim_username'])) {
         return array('error' => 4, 'message' => 'Error fetching Vimeo feed: <span class="social-feed-error">No user found.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     try {
         $rss = Feed::loadRss('http://vimeo.com/' . $options['sa_vim_username'] . '/videos/rss');
     } catch (FeedException $e) {
         return array('error' => 5, 'message' => 'Error fetching Vimeo feed: <span class="social-feed-error">' . $e->getMessage() . '</span>');
     }
     if (count($rss->item) == 0) {
         return array('error' => 1, 'message' => 'No items found in feed.');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $namespaces = $item->getNameSpaces(true);
             $dc = $item->children($namespaces['dc']);
             $p['author'] = (string) $dc->creator;
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $video_id = substr($link, strrpos($link, '/') + 1);
             $p['video_id'] = $video_id;
             $vimeo_data = file_get_contents('http://vimeo.com/api/v2/video/' . $video_id . '.json');
             $vimeo_data = json_decode($vimeo_data);
             $vimeo_thumb = $vimeo_data[0]->thumbnail_large;
             $p['picture'] = $vimeo_thumb;
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new Vimeo items found.');
     }
 }
开发者ID:rexyzhoang,项目名称:wpp,代码行数:49,代码来源:VimeoFeed.php

示例3: __construct

 /**
  *  
  * @param   $url the url of the feed
  * @param   $config the array containing the configuration parameters: "limit", "timezone", "dateformat", "encoding"
  */
 public function __construct($url, $config = [])
 {
     //load xml from the Feed Class
     $rss = \Feed::loadRss($url);
     $dom = new \DOMDocument();
     $dom->loadHTML($rss->item->description);
     $this->manageConf($config);
     date_default_timezone_set($this->config['timezone']);
     $count = 0;
     foreach ($rss->item as $item) {
         $this->push($this->parseDescription($item));
         if ($this->config['limit'] && ++$count == $this->config['limit']) {
             break;
         }
     }
 }
开发者ID:anarcociclista,项目名称:mediumfeed,代码行数:21,代码来源:MediumFeed.php

示例4: getFeed

 public function getFeed($options)
 {
     if (empty($options['sa_rss_url'])) {
         return array('error' => 4, 'message' => 'Error fetching RSS feed: <span class="social-feed-error">No URL provided.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     try {
         $rss = Feed::loadRss($options['sa_rss_url']);
     } catch (FeedException $e) {
         return array('error' => 5, 'message' => 'Error fetching RSS feed: <span class="social-feed-error">' . $e->getMessage() . '</span>');
     }
     if (count($rss->item) == 0) {
         return array('error' => 1, 'message' => 'No items found in feed.');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $author = (string) $item->author;
             if (empty($author)) {
                 $namespaces = $item->getNameSpaces(true);
                 $dc = $item->children($namespaces['dc']);
                 $p['author'] = (string) $dc->creator;
             }
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new RSS items found.');
     }
 }
开发者ID:rexyzhoang,项目名称:wpp,代码行数:46,代码来源:RssFeed.php

示例5: getFeed

 public function getFeed($options)
 {
     if (empty($options['sa_yt_username'])) {
         return array('error' => 4, 'message' => 'Error fetching YouTube feed: <span class="social-feed-error">No user found.</span>');
     }
     $since_time = empty($options['sa_since_time']) ? 1 : $options['sa_since_time'];
     $rss = Feed::loadRss('http://youtube.com/rss/user/' . $options['sa_yt_username']);
     if (count($rss->item) == 0) {
         return array('error' => 6, 'message' => 'Error fetching YouTube feed: <span class="social-feed-error">No items found or user does not exist.</span>');
     }
     $data = array();
     $date_added = time();
     $item_timestamps = array();
     foreach ($rss->item as $item) {
         // $item_timestamp = (int)$item->timestamp;
         $item_timestamp = strtotime((string) $item->pubDate);
         if ($item_timestamp > $since_time) {
             $p = array();
             $p['id'] = (string) $item->guid;
             $p['message'] = (string) $item->title;
             $p['description'] = (string) $item->description;
             $link = (string) $item->link;
             $p['link'] = $link;
             $p['author'] = (string) $item->author;
             $p['date_added'] = $date_added;
             $p['date_created'] = strtotime((string) $item->pubDate);
             $video_id = substr($link, strrpos($link, 'watch?v=') + 8);
             $video_id = substr($video_id, 0, strpos($video_id, '&'));
             $p['video_id'] = $video_id;
             $p['picture'] = 'http://img.youtube.com/vi/' . $video_id . '/0.jpg';
             $item_timestamps[] = $item_timestamp;
             array_push($data, $p);
         }
     }
     if (count($data) > 0) {
         $res = array('data' => $data, 'since_time' => max($item_timestamps));
         return $res;
     } else {
         return array('error' => 3, 'message' => 'No new YouTube items found.');
     }
 }
开发者ID:rexyzhoang,项目名称:wpp,代码行数:41,代码来源:YouTubeFeed.php

示例6: readFeed

 protected function readFeed($url)
 {
     // Read feed
     $rss = \Feed::loadRss($url);
     $out = "";
     $count = 0;
     // Add feed information to the output
     $out .= '<h2>' . $rss->title . '</h2>';
     $out .= '<p>' . $rss->description;
     $out .= '<br><a href="' . $rss->link . '">Länk</a></p>';
     // Add feed items to the output (limited to three items)
     foreach ($rss->item as $item) {
         if ($count++ == 3) {
             return $out;
         }
         $out .= '<h3>' . $item->title . '</h3>';
         $out .= '<p>' . $item->description;
         $out .= '<br><a href="' . $item->link . '">Länk</a></p>';
     }
     return $out;
     // In case of fewer than 3 elements
 }
开发者ID:bjurnemark,项目名称:Anax-MVC,代码行数:22,代码来源:PackageController.php

示例7: header

<?php

header('Content-Type: text/html; charset=utf-8');
if (!ini_get('date.timezone')) {
    date_default_timezone_set('Europe/Prague');
}
require_once 'src/Feed.php';
$rss = Feed::loadRss('http://phpfashion.com/feed/rss');
?>

<h1><?php 
echo htmlSpecialChars($rss->title);
?>
</h1>

<p><i><?php 
echo htmlSpecialChars($rss->description);
?>
</i></p>

<?php 
foreach ($rss->item as $item) {
    ?>
	<h2><a href="<?php 
    echo htmlSpecialChars($item->link);
    ?>
"><?php 
    echo htmlSpecialChars($item->title);
    ?>
</a>
	<small><?php 
开发者ID:benefit0205,项目名称:rss-php,代码行数:31,代码来源:example-rss.php

示例8: function

<?php

use Cmfcmf\OpenWeatherMap;
use Cmfcmf\OpenWeatherMap\Exception as OWMException;
$app->get('/', function () use($app) {
    $view = [];
    // NEWS SLIDE
    Feed::$cacheExpire = "30 minutes";
    Feed::$cacheDir = "/tmp";
    $rss_npr = Feed::loadRss("http://www.npr.org/rss/rss.php?id=1001");
    $rss_techmeme = Feed::loadRss("http://www.techmeme.com/feed.xml");
    $view['news_npr'] = $rss_npr->item;
    $view['news_techmeme'] = $rss_techmeme->item;
    // WEATHER SLIDE
    $lang = 'en';
    $units = 'imperial';
    $owm = new OpenWeatherMap(null, new WeatherCache(), 60);
    try {
        $weather = $owm->getWeather('Milpitas', $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601");
        $rawForecast = $owm->getWeatherForecast("Milpitas", $units, $lang, "06b7f9678c0512b3b8ca9e94758a9601", 3);
        $forecast = [];
        while ($rawForecast->valid()) {
            $chunk = $rawForecast->current();
            $forecast[] = ['start' => $chunk->time->from->getTimestamp() - 3600 * 8, 'low' => $chunk->temperature->min->getValue(), 'avg' => $chunk->temperature->now->getValue(), 'max' => $chunk->temperature->max->getValue(), 'pressure' => $chunk->pressure->getValue(), 'precipitation' => $chunk->precipitation->getValue(), 'humidity' => $chunk->humidity->getValue(), 'clouds' => $chunk->clouds->getValue()];
            $rawForecast->next();
        }
        $forecastAvg = [];
        $forecastLow = [];
        $forecastHigh = [];
        $forecastPrecip = [];
        $fp = 0.5;
开发者ID:BIGjuevos,项目名称:pi-hud,代码行数:31,代码来源:home.php

示例9: Logger

<?php

$title = 'CRITTER.SPACE';
include 'thatfunk/header.php';
require 'vendor/autoload.php';
use Egulias\EmailValidator\EmailValidator;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$log = new Logger('CRTR.SPACE');
$log->pushHandler(new StreamHandler('../space.log', Logger::DEBUG));
// add records to the log
$log->addInfo('Hit from ' . $_SERVER['REMOTE_ADDR']);
$url = "https://earthbot.net/rss/feed.xml";
$rss = Feed::loadRss($url);
//include ('thatfunk/fakefeed.txt');
echo '<h3 style="text-align: center;">Just updated! <strong>DEC-06-2015</strong></h3><hr>';
echo '<h2 style="text-align: center;">"<a href="https://earthbot.net/chat/">Lots</a> of <a href="http://rogue.news">new</a> <a href="https://earthbot.net/games/">stuff"</a></h2><hr>';
echo '<h2 style="text-align: center;"><a href="http://bugs.earthbot.net">report bugs</a></h2><hr>';
echo '<h3 style="color:green;">PH/TXT: 541- [two] 95-7172</h1><hr>';
echo '<h3 style="color:green;">EMAIL: aerth [at sign] sdf.org</h1><hr>';
echo '<h3 style="color:green;">IM/XMPP: aerth [at sign] earthbot.net </h1><hr>';
?>
<h3>Here is a great radio station I listen to frequently</h3>
<iframe src="http://tunein.com/embed/player/s198870/" style="width:100%;height:100px;" scrolling="no" frameborder="no"></iframe>
<?php 
//echo 'Link: ', $atom->link;
echo '<div class="large-6 small-6 columns" style="padding-left: 1px; padding-right: 1px;margin-right: 0px;margin-left: 0px;">';
echo '<h2>Earthbot\'s Latest Log</h2><p><a href="https://earthbot.net">View on Earthbot</a><hr>';
echo '<rss version="0.92" xml:base="https://earthbot.net/"><link base="https://earthbot.net/">';
foreach ($rss->item as $item) {
    $description = str_replace('<a href="', '<a href="https://earthbot.net/', $item->description);
开发者ID:aerth,项目名称:critter.space,代码行数:31,代码来源:index.php

示例10: function

    // create template
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/' . $lang . '.latte');
    // register template helpers like {$foo|date}
    $template->registerHelper('date', function ($date) use($lang) {
        if ($lang === 'en') {
            return date('F j, Y', (int) $date);
        } else {
            static $months = array(1 => 'leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec');
            $date = getdate((int) $date);
            return "{$date['mday']}. {$months[$date['mon']]} {$date['year']}";
        }
    });
    $template->registerHelper('tweet', function ($s) {
        return Twitter::clickable($s);
    });
    $template->registerHelper('rss', function ($path) {
        return Feed::loadRss($path);
    });
    $template->registerHelper('texy', array(new Texy(), 'process'));
    return $template;
});
// http://davidgrudl.com/sources
$container->router[] = new Route('sources', function ($presenter) {
    $template = $presenter->createTemplate()->setFile(__DIR__ . '/app/sources.latte');
    $template->registerHelper('source', function ($file, $lang = NULL) {
        return preg_replace('#<br ?/?>#', '', highlight_file($file, TRUE));
    });
    return $template;
});
// Run the application!
$container->application->run();
开发者ID:radopetrik,项目名称:davidgrudl.com,代码行数:31,代码来源:index.php

示例11: header

<?php

header('Content-Type: text/html; charset=utf-8');
require_once 'feed.class.php';
$rss = Feed::loadRss('http://bowdoinorientexpress.com/rss');
?>

<h1><?php 
echo htmlSpecialChars($rss->title);
?>
</h1>

<p><i><?php 
echo htmlSpecialChars($rss->description);
?>
</i></p>

<?php 
foreach ($rss->item as $item) {
    ?>
    <h2><a href="<?php 
    echo htmlSpecialChars($item->link);
    ?>
"><?php 
    echo htmlSpecialChars($item->title);
    ?>
</a>
    <small><?php 
    echo date("j.n.Y H:i", (int) $item->timestamp);
    ?>
</small></h2>
开发者ID:hdiprinzio,项目名称:bonus,代码行数:31,代码来源:load-rss.php

示例12: foreach

    exit;
}
foreach ($blogFeed->item as $item) {
    $dateTime = new DateTime($item->pubDate);
    if ($dateTime <= $mostRecentBlogDateTime) {
        // break;
    }
    $uniqueBlogCheck = $db->getRead()->fetchValue("SELECT 1 FROM `jpemeric_stream`.`blog` WHERE `permalink` = :guid LIMIT 1", ['guid' => (string) $item->guid]);
    if ($uniqueBlogCheck !== false) {
        continue;
    }
    $dateTime->setTimezone(new DateTimeZone('America/Phoenix'));
    $metadata = json_decode(json_encode($item), true);
    $db->getWrite()->perform("INSERT INTO `jpemeric_stream`.`blog` (`permalink`, `datetime`, `metadata`) " . "VALUES (:permalink, :datetime, :metadata)", ['permalink' => (string) $item->guid, 'datetime' => $dateTime->format('Y-m-d H:i:s'), 'metadata' => json_encode($metadata)]);
}
$mostRecentBlogCommentDateTime = $db->getRead()->fetchValue("SELECT `datetime` FROM `jpemeric_stream`.`blog_comment` ORDER BY `datetime` DESC LIMIT 1");
$mostRecentBlogCommentDateTime = new DateTime($mostRecentBlogCommentDateTime);
$commentFeed = Feed::loadRss('https://blog.jacobemerick.com/rss-comments.xml');
foreach ($commentFeed->item as $item) {
    $dateTime = new DateTime($item->pubDate);
    if ($dateTime <= $mostRecentBlogCommentDateTime) {
        break;
    }
    $uniqueBlogCommentCheck = $db->getRead()->fetchValue("SELECT 1 FROM `jpemeric_stream`.`blog_comment` WHERE `permalink` = :guid LIMIT 1", ['guid' => (string) $item->guid]);
    if ($uniqueBlogCommentCheck !== false) {
        continue;
    }
    $dateTime->setTimezone(new DateTimeZone('America/Phoenix'));
    $metadata = json_decode(json_encode($item), true);
    $db->getWrite()->perform("INSERT INTO `jpemeric_stream`.`blog_comment` (`permalink`, `datetime`, `metadata`) " . "VALUES (:permalink, :datetime, :metadata)", ['permalink' => (string) $item->guid, 'datetime' => $dateTime->format('Y-m-d H:i:s'), 'metadata' => json_encode($metadata)]);
}
开发者ID:jacobemerick,项目名称:web-scripts,代码行数:31,代码来源:fetch-blog-activity.php


注:本文中的Feed::loadRss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。