Example #1
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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');
Example #2
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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 the channel elements
//Use wrapper functions for common channel elements
$TestFeed->setTitle('Testing & Checking the RSS writer class');
$TestFeed->setLink('http://www.ajaxray.com/projects/rss');
$TestFeed->setDescription('This is a test of creating a RSS 2.0 feed Universal Feed Writer');
//Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0
$TestFeed->setImage('Testing & Checking the RSS writer class', 'http://www.ajaxray.com/projects/rss', 'http://www.rightbrainsolution.com/_resources/img/logo.png');
//Let's add some feed items: Create two empty Item instances
$itemOne = $TestFeed->createNewItem();
$itemTwo = $TestFeed->createNewItem();
//Add item details
$itemOne->setTitle('The title of the first entry.');
$itemOne->setLink('http://www.google.de');
$itemOne->setDate(time());
$itemOne->setDescription('And here\'s the description of the entry.');
$itemTwo->setTitle('Lorem ipsum');
$itemTwo->setLink('http://www.example.com');
$itemTwo->setDate(1234567890);
$itemTwo->setDescription('Lorem ipsum dolor sit amet, consectetur, adipisci velit');
//Now add the feed item
$TestFeed->addItem($itemOne);
$TestFeed->addItem($itemTwo);
Example #3
0
$TestFeed = new RSS2();
if ($emission != "") {
    $TestFeed->setDescription('Tous les podcasts de l\'émission ' . $emission . ' diffusés sur Radio Campus Clermont-Ferrand');
    $url = 'http://www.campus-clermont.net/onair/podcast/player/?search=' . urlencode($emission);
    $title = 'Podcasts de l\'émission ' . $emission . ' sur Radio Campus Clermont-Ferrand';
    $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/ws/?req=image&t=" . urlencode($emission)));
    $image = 'http://' . $_SERVER["HTTP_HOST"] . $jsonObject[0]->uri;
} else {
    $TestFeed->setDescription('Tous les podcasts de Radio Campus Clermont-Ferrand');
    $url = 'http://www.campus-clermont.net/onair/podcast/player/';
    $title = 'Le podcast de Radio Campus';
    $image = "http://www.campus-clermont.net/onair/podcast/player/images/logo.png";
}
$TestFeed->setTitle($title);
$TestFeed->setLink($url);
$TestFeed->setImage($title, $url, $image);
if ($emission != "") {
    $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?q=" . urlencode($emission)));
} else {
    if ($sans100) {
        $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?action=sans100"));
    } else {
        $jsonObject = json_decode(file_get_contents("http://" . $_SERVER['HTTP_HOST'] . "/onair/podcast/player/ws/search.php?action=all"));
    }
}
$m2Txt = array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
$i = 0;
foreach ($jsonObject as $entry) {
    if ($i > 64) {
        break;
    }
Example #4
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;
 }