Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Public Access to RSS Feeds

0 votes
255 views
asked Oct 26, 2011 in Q2A Core by Matthew Riches
Hi all,

   My Q2A is totally locked down with an externally users file. However I want RSS feeds to be publically accessible so I can use them in SharePoint and over services.

Is there a way to enabled RSS feeds to be public, I am assuming I need to add something to the "qa-feed.php" file, but I'm not sure what...

Anyone have any ideas?
commented Oct 26, 2011 by Scott
What do you mean by "locked down with an externally users file"? Why doesn't `/feed/questions.rss`work?
commented Oct 27, 2011 by Matthew Riches
I've followed the instructions to setup the external users file to work with SSO Windows credentials, this means however that IIS needed to be setup so that it had Intergrated Windows security site-wide. I have developed a solution however, that I will add as an answer.

1 Answer

0 votes
answered Oct 27, 2011 by Matthew Riches

So, I've written a solution, not sure if this is the 'write' way to do it, but it seemed the easiest in my eyes.

The problem I had is that because Q2A is effectively created on the fly, there were no specific files I could set in IIS to allow for anonymous access, so I added this to the bottom of the file /qa-include/qa-feed.php

 

$rawrss = implode("\n", $lines);
$filename = 'rss.xml';
$rsscontent = $rawrss;

if (is_writable($filename)) {

    if (!$handle = fopen($filename, 'a')) {
         exit;
    }

    if (fwrite($handle, $rsscontent) === FALSE) {
        exit;
    }

    //done

    fclose($handle);

} else {
    //error check file is writeable
}

This uses the already defined $lines variable and writes this to a static RSS file called rss.xml in the root. This means that everytime the RSS feed is viewed (I only need one RSS feed, I guess you can do some clever matching to write different files), the file is updated. I also setup a scheduled task in PHP to run this file every 2 hours (just in case no one views it).

Then in IIS I simply set this file and this file only to have anonymous access, and bam, I can now use the feed in SharePoint, Blackboard and other services.

...