Пример #1
0
 private function prepareFeed($title, $description)
 {
     $feed = new RSS2();
     $feed->setTitle($title);
     $feed->setLink($this->getCurrentUrl());
     $feed->setDescription($description);
     $feed->setDate(date(DATE_RSS, time()));
     $feed->setChannelElement('pubDate', date(\DATE_RSS, strtotime('today midnight')));
     return $feed;
 }
Пример #2
0
include 'RSS2.php';
include 'db_conn.php';
date_default_timezone_set('Asia/Shanghai');
use FeedWriter\RSS2;
if ($_GET['id']) {
    $name = $_GET['id'];
    $sql = "SELECT * FROM list WHERE name = '{$name}'";
    mysql_query('set names utf8');
    mysql_query("set character set 'utf8'");
    $retval = mysql_query($sql);
    $row = mysql_fetch_array($retval, MYSQL_ASSOC);
    $TestFeed = new RSS2();
    $TestFeed->setTitle($row['name']);
    $TestFeed->setLink($row['link']);
    $TestFeed->setDescription($row['description']);
    $TestFeed->setChannelElement('language', 'zh-CN');
    $TestFeed->setDate(date(DATE_RSS, time()));
    $TestFeed->setChannelElement('copyright', $row['account']);
    $TestFeed->addGenerator();
    mysql_query("set character set 'utf8'");
    $sql = "SELECT * FROM `{$name}` ORDER BY lastModified DESC";
    mysql_select_db('weixincrawler');
    $retval = mysql_query($sql);
    if (!$retval) {
        die('Could not get data: ' . mysql_error());
    }
    while ($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {
        $newItem = $TestFeed->createNewItem();
        $newItem->setTitle($row["title"]);
        $newItem->setLink($row["url"]);
        $newItem->setDescription($row["description"]);
Пример #3
0
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
// Creating an instance of RSS2 class.
$TestFeed = new RSS2();
// Setting some basic channel elements. These three elements are mandatory.
$TestFeed->setTitle('Testing & Checking the Feed Writer project');
$TestFeed->setLink('https://github.com/mibe/FeedWriter');
$TestFeed->setDescription('This is just an example how to use the Feed Writer project in your code.');
// Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0,
// which were set above.
$TestFeed->setImage('Testing & Checking the Feed Writer project', 'https://github.com/mibe/FeedWriter', 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Rss-feed.svg/256px-Rss-feed.svg.png');
// Use core setChannelElement() function for other optional channel elements.
// See http://www.rssboard.org/rss-specification#optionalChannelElements
// for other optional channel elements. Here the language code for American English and
$TestFeed->setChannelElement('language', 'en-US');
// The date when this feed was lastly updated. The publication date is also set.
$TestFeed->setDate(date(DATE_RSS, time()));
$TestFeed->setChannelElement('pubDate', date(\DATE_RSS, strtotime('2013-04-06')));
// You can add additional link elements, e.g. to a PubSubHubbub server with custom relations.
// It's recommended to provide a backlink to the feed URL.
$TestFeed->setSelfLink('http://example.com/myfeed');
$TestFeed->setAtomLink('http://pubsubhubbub.appspot.com', 'hub');
// You can add more XML namespaces for more custom channel elements which are not defined
// in the RSS 2 specification. Here the 'creativeCommons' element is used. There are much more
// available. Have a look at this list: http://feedvalidator.org/docs/howto/declare_namespaces.html
$TestFeed->addNamespace('creativeCommons', 'http://backend.userland.com/creativeCommonsRssModule');
$TestFeed->setChannelElement('creativeCommons:license', 'http://www.creativecommons.org/licenses/by/1.0');
// If you want you can also add a line to publicly announce that you used
// this fine piece of software to generate the feed. ;-)
$TestFeed->addGenerator();
Пример #4
0
$siteConfig = \AdService\SiteConfigFactory::factory($_GET["url"]);
$ads = $parser->process($content, $filter, parse_url($_GET["url"], PHP_URL_SCHEME));
$title = $siteConfig->getOption("site_name");
$urlParams = parse_url($_GET["url"]);
if (!empty($urlParams["query"])) {
    parse_str($urlParams["query"], $aQuery);
    if (!empty($aQuery["q"])) {
        $title .= " - " . $aQuery["q"];
    }
}
$feeds = new RSS2();
$feeds->setTitle($siteConfig->getOption("site_name"));
$feeds->setLink($siteConfig->getOption("site_url"));
$feeds->setSelfLink(!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? "https" : "http" . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$feeds->setDescription("Flux RSS de la recherche : " . $_GET["url"]);
$feeds->setChannelElement("language", "fr-FR");
// The date when this feed was lastly updated. The publication date is also set.
$feeds->setDate(date(DATE_RSS, time()));
$feeds->setChannelElement("pubDate", date(\DATE_RSS, strtotime("2013-04-06")));
$feeds->addGenerator();
if (count($ads)) {
    foreach ($ads as $ad) {
        $item = $feeds->createNewItem();
        $item->setTitle($ad->getTitle());
        $item->setLink($ad->getLink());
        $item->setDescription(require DOCUMENT_ROOT . "/app/rss/views/rss-ad.phtml");
        $item->setDate($ad->getDate());
        $item->setId(md5($ad->getId()));
        $feeds->addItem($item);
    }
}
Пример #5
0
 /**
  * Get RSS feed
  *
  * Converts a JSON array of event objects into an RSS feed
  * 
  * @param mixed $events Array of events to be converted
  *
  * @return string Complete markup for RSS feed
  */
 public function RSSify($events)
 {
     $feed = new RSS2();
     $this->getBuildings(null, false);
     $feed->setTitle('Upcoming Events');
     $feed->setLink('http://events.uoit.ca');
     $feed->setImage('Upcoming Events', 'http://events.uoit.ca', 'http://events.uoit.ca/img/uoit_logo.svg');
     $feed->setDescription('Upcoming events, deadlines and more at the University of Ontario Institute of Technology');
     $feed->setChannelElement('language', 'en-US');
     $feed->setDate(date(DATE_RSS, time()));
     $feed->setSelfLink(currentURL);
     $feed->setAtomLink('http://feeds.feedburner.com/uoit/events', 'hub');
     foreach ($events as $key => $event) {
         $time = date('g:i', strtotime($event['event_startdate']));
         $ampm = date('a', strtotime($event['event_startdate'])) == 'am' ? 'a.m.' : 'p.m.';
         $item = $feed->createNewItem();
         $item->setTitle($event['event_name']);
         $item->setLink('http://events.uoit.ca/event/' . $event['id']);
         $item->setId($event['id'], false);
         $item->setDescription($event['event_description']);
         $item->setDate(date("Y-m-d H:i:s"));
         $item->addElement('date', strtotime($event['event_startdate']));
         $item->addElement('time', $time . ' ' . $ampm);
         if ($event['contact_event_firstname'] && $event['contact_event_lastname'] && $event['contact_event_email']) {
             $item->setAuthor($event['contact_event_firstname'] . ' ' . $event['contact_event_lastname'], $event['contact_event_email']);
         }
         $item->addElement('location', $this->parseLocation($this->buildings, $event['location_campus'], $event['location_building'], $event['location_room'], $event['location_other']));
         $feed->addItem($item);
     }
     $output = $feed->generateFeed();
     return $output;
 }