开发者

Facebook Fan Page feed

Im trying to fetch a feed from a Page in Facebook which works fine if i use a browser to get the feed - But when im trying to build a script that has to fetch the XML, it returns HTML, any ideas why ? And is there any other way to get the XML for a Fan feed??

  • Im using this URL: http://www.facebook.com/feeds/page.php?format=atom10&id=302236852436

The C# code is:

private string GetFacebookPosts(string FacebookID, int NumberOfPosts)
    {

        string feedadress = "http://www.facebook.com/feeds/page.php?format=atom10&id=" + FacebookID.ToString();
        WebClient web = new WebClient();
        return web.DownloadString(feedadress);
    }

    #region Module rendering

    /// <summary>
    /// Renders the module output XML for frontend
    /// </summary>      
    protected override string R开发者_开发技巧ender(Page page)
    {
        string FacebookResponse = GetFacebookPosts(ModuleEditionInstance.FacebookID, ModuleEditionInstance.NumberOfPosts);

        XmlDocument FacebookXML = new XmlDocument();
        FacebookXML.LoadXml(FacebookResponse);


        // Transform the rendered xml with the current XslSnippet 
        return ApplyXslSnippet(FacebookXML.InnerXml, page);
    }

    #endregion`

When getting the response from Facebook i get an HTML page, with a response that it's an incompatible browser im coming from - If that is the case, then how do i get the feed ?


What if you pretend the client is a known browser like IE by passing its User-Agent header:

web.Headers["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜