Tutorials

Download

Adding an RSS feed

Need RSS? You got it. Osmek makes adding an RSS feed to your site a cinch. Just set the format parameter of the fetch_feed function to 'rss', and Osmek will return formatted RSS.

The example below echos an RSS feed for the desired section_id. Make sure to replace the variables below with your api_key and the desired section_id.

feed.php

<?php
    
include('Osmek.php');
    
$osmek = new Osmek('[replace_with_api_key]');
    
    
header("Content-Type: application/rss+xml");
    echo 
$osmek->fetch_feed(array('section_id' => '[replace_with_section_id]''format' => 'rss'));
    
?>

Although linking to feed.php will work, it's much better practice to use the proper xml extension. You can use htaccess to rewrite as feed.xml

.htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^feed.xml$        http://example.com/feed\.php [L]

Then link to feed.xml

index.php

<link rel="alternate" type="application/rss+xml" title="RSS" href="http://example.com/feed.xml" />