Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PHP Extension) Read RSS FeedSample code showing how to read an RSS feed and emit the contents.
<?php // The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number. // For example, if using Chilkat v9.5.0.48, then include as shown here: include("chilkat_9_5_0.php"); $rss = new CkRss(); // Download from the feed URL: $success = $rss->DownloadRss('http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml'); if ($success != true) { print $rss->lastErrorText() . "\n"; exit; } // Get the 1st channel. // rssChannel is a CkRss $rssChannel = $rss->GetChannel(0); if ($rss->get_LastMethodSuccess() == false) { print 'No channel found in RSS feed.' . "\n"; exit; } // Display the various pieces of information about the channel: print 'Title: ' . $rssChannel->getString('title') . "\n"; print 'Link: ' . $rssChannel->getString('link') . "\n"; print 'Description: ' . $rssChannel->getString('description') . "\n"; // For each item in the channel, display the title, link, // publish date, and categories assigned to the post. $numItems = $rssChannel->get_NumItems(); for ($i = 0; $i <= $numItems - 1; $i++) { // rssItem is a CkRss $rssItem = $rssChannel->GetItem($i); print '----' . "\n"; print 'Title: ' . $rssItem->getString('title') . "\n"; print 'Link: ' . $rssItem->getString('link') . "\n"; print 'pubDate: ' . $rssItem->getString('pubDate') . "\n"; $numCategories = $rssItem->GetCount('category'); if ($numCategories > 0) { for ($j = 0; $j <= $numCategories - 1; $j++) { print ' category: ' . $rssItem->mGetString('category',$j) . "\n"; } } } ?> |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.