Pull RSS Feeds From Facebook Page

前端 未结 3 2080
挽巷
挽巷 2021-02-06 11:53

I need help to pull RSS feeds from a facebook page I\'m using the following code but it keeps giving me an error :

string url = 
    \"https://www.facebook.com/f         


        
3条回答
  •  一整个雨季
    2021-02-06 12:32

    Facebook will return HTML in this instance because it doesn't like the User Agent supplied by XmlReader. Since you can't customize it, you will need a different solution to grab the feed. This should solve your problem:

    var req = (HttpWebRequest)WebRequest.Create(url);
    req.Method = "GET";
    req.UserAgent = "Fiddler";
    
    var rep = req.GetResponse();
    var reader = XmlReader.Create(rep.GetResponseStream());
    
    SyndicationFeed feed = SyndicationFeed.Load(reader);
    

    This is strictly a behavior of Facebook, but the proposed change should work equally well for other sites that are okay with your current implementation.

提交回复
热议问题