Click here to Skip to main content
15,117,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI all,

I am having some problem while consuming rss feed from facebook. It is sending back http://www.facebook.com/browser.php as a response.This is the behaviour of facebook rss feeds. So i am not able to read it. Can anyone help me in consuming rss feeds in asp.net applications.

Any help will be highly appreciated.
Thanks in advance.
Posted

I think Facebook news rss requires authentication?

browser.php redirects to PageNotFound error. :sigh:

I think this might be the issue with authentication.
   
No authentication is right. There was some problem in code itself. Correct code for this is:

HttpWebRequest request = ((HttpWebRequest)(WebRequest.Create(strURL)));
request.Timeout = 10000;
request.UserAgent = "Code Sample";
HttpWebResponse response = (HttpWebResponse)(request.GetResponse());
Encoding enc = Encoding.GetEncoding(1252);
StreamReader responseStream = new StreamReader(response.GetResponseStream(), enc);
string strHTML = responseStream.ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strHTML);
DataTable dtRss = new DataTable();
dtRss.Columns.Add("TITLE");
dtRss.Columns.Add("LINK");
dtRss.Columns.Add("DESCRIPTION");
dtRss.Columns.Add("PUBDATE");
XmlNodeList rssItems = xmlDoc.SelectNodes("rss/channel/item");
for (int i = 0; i < rssItems.Count; i++)
{

DataRow dr;
dr = dtRss.NewRow();
XmlNode rssDetail;
rssDetail = rssItems.Item(i).SelectSingleNode("title");
if (rssDetail != null)
dr["TITLE"] = rssDetail.InnerText;
rssDetail = rssItems.Item(i).SelectSingleNode("link");
if (rssDetail != null)
dr["LINK"] = rssDetail.InnerText;
rssDetail = rssItems.Item(i).SelectSingleNode("description");
if (rssDetail != null)
dr["DESCRIPTION"] = rssDetail.InnerText;
rssDetail = rssItems.Item(i).SelectSingleNode("pubDate");
if (rssDetail != null)
{
string strDate = rssDetail.InnerText;
DateTime dtPubDate = Convert.ToDateTime(strDate);
dr["PUBDATE"] = dtPubDate.ToLongDateString() + " " + dtPubDate.ToShortTimeString();
}
dtRss.Rows.Add(dr);
}

Thanks for your help.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900