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


PHP RSSFeed::setLastBuildDate方法代码示例

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


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

示例1: addPageToRSSFeed

function addPageToRSSFeed($html, RSSFeed $rssFeed)
{
    $html = preg_replace("#<script.*?</script>#is", "", $html);
    # Strip out <script> tags so loadHTML() parses the page correctly for $xpath->query()
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    $xpath = new DOMXPath($dom);
    # Get the post wrapper divs
    $postDivs = $xpath->query('/descendant::div[@id="posts"]/div[starts-with(@id,"edit") and @class="postbit-wrapper "]');
    # Thread URL
    $pageURL = current(iterator_to_array($xpath->query('/html/head/link[@rel="canonical"]/@href')))->nodeValue;
    # Title
    $title = current(iterator_to_array($xpath->query('//div[@id = "thread-header-bloglike"]//h1')))->nodeValue;
    $rssFeed->title = $title;
    # Get the post element divs
    foreach ($postDivs as $postDiv) {
        $rssItem = new RSSItem();
        # Title (author)
        $rssItem->title = '[Post]';
        // Default to "[Post]" on first post
        foreach ($xpath->query('.//a[starts-with(@class, "bigfusername")]', $postDiv) as $postAuthor) {
            $rssItem->title = trim($postAuthor->nodeValue);
            $rssItem->author = trim($postAuthor->nodeValue);
            break;
        }
        # Link, GUID
        $rssItem->link = $pageURL;
        // Default to page URL on first post
        $rssItem->guid = $rssItem->link;
        foreach ($xpath->query('.//a[@class="postCount"]/@href', $postDiv) as $postLink) {
            # Strip the 's' parameter out since it changes every so often....
            $parsedURL = parse_url($postLink->nodeValue);
            $queryStr = $parsedURL['query'];
            parse_str($queryStr, $queryParams);
            unset($queryParams['s']);
            $rssItem->link = 'http://forum.xda-developers.com/' . $parsedURL['path'] . '?' . http_build_query($queryParams);
            $rssItem->guid = $rssItem->link;
            break;
        }
        # Description
        foreach ($xpath->query('.//div[starts-with(@id, "post_message") and starts-with(@class, "post-text")]', $postDiv) as $postMsgDiv) {
            # Strip ad
            foreach ($xpath->query('.//div[@class="purchad"]', $postDiv) as $postAd) {
                $postAd->parentNode->removeChild($postAd);
            }
            $rssItem->description = cleanPostMessageHTML($dom->saveXML($postMsgDiv));
            break;
        }
        # Publication Date
        $rssItem->setPubDate(new DateTime('1900-01-01'));
        // Default to 1st JAN 1900 on first post... oh well...
        $rssFeed->setLastBuildDate($rssItem->getPubDate());
        foreach ($xpath->query('.//span[@class="time"]', $postDiv) as $postDateSpan) {
            $rssItem->setPubDate(getXDADate(trim($postDateSpan->nodeValue)));
            $rssFeed->setLastBuildDate($rssItem->getPubDate());
            # Set the feed's lastBuildDate to the last post's date
            break;
        }
        $rssFeed->addRSSItem($rssItem);
    }
}
开发者ID:klo2k,项目名称:php-rss,代码行数:61,代码来源:xda.php

示例2: RSSFeed

mysql_select_db('website', $connection);
try {
    // Create the new instance of the RSS Feed
    $rssFeed = new RSSFeed('utf-8');
    // Activate the string protection
    $rssFeed->setProtectString(true);
    // Set the feed title
    $rssFeed->setTitle('My blog : the best in the world');
    // Set the feed description
    $rssFeed->setDescription('A little blog, which talks about Web programming');
    // Set the feed link
    $rssFeed->setLink('http://www.mywebsite.com/blog/rss/posts.php');
    // Set the feed publication date
    $rssFeed->setPubDate('2007-08-01');
    // Set the feed last build date
    $rssFeed->setLastBuildDate(date('Y-m-d'));
    // Set the feed webmaster
    $rssFeed->setWebMaster('me@mywebsite.com', 'John Doe');
    // Set the feed managing editor
    $rssFeed->setManagingEditor('me@mywebsite.com', 'John Doe');
    // Set the feed image
    $rssFeed->setImage('http://www.mywebsite.com/image/logo.jpg', 'My Logo', 'My blog', 100, 200);
    // Set the feed categories
    $rssFeed->setCategory('http://technorati.com/posts/tag/php', 'PHP Language');
    $rssFeed->setCategory('http://technorati.com/posts/tag/html', 'HTML Language');
    $rssFeed->setCategory('http://technorati.com/posts/tag/java', 'Java Language');
    $rssFeed->setCategory('http://technorati.com/posts/tag/asp', 'ASP Language');
    // Set the feed copyright
    $rssFeed->setCopyright('(C) Copyright 2007 - MyWebsite - All rights reserved');
    // Set the feed rating
    $rssFeed->setRating('(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS--000 1))');
开发者ID:kxopa,项目名称:WebSite-PHP,代码行数:31,代码来源:example2.php


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