【发布时间】:2011-04-05 15:53:03
【问题描述】:
我试图从 Facebook 中的页面获取提要,如果我使用浏览器获取提要,这可以正常工作 - 但是当我尝试构建必须获取 XML 的脚本时,它返回 HTML,有什么想法吗?还有其他方法可以获取 Fan feed 的 XML 吗??
C#代码是:
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 Render(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`
当我从 Facebook 获得响应时,我得到一个 HTML 页面,它的响应是来自不兼容的浏览器 - 如果是这种情况,那么我如何获取提要?
【问题讨论】:
-
我猜你没有提供所需的与身份验证相关的 cookie。然后服务器将重定向到登录页面。