/// <summary> /// Render the control /// </summary> /// <param name="output"></param> protected override void RenderContents(HtmlTextWriter output) { //output.Write(String.Format("<div style=\"border: {0}px solid #1B8BFC;width:{1}px;\">",BorderWidth, _Width)); if (_FacebookID != null) _FacebookID = _FacebookID.Trim(); if (string.IsNullOrEmpty(_FacebookID)) throw new ArgumentNullException("FacebookID", "Required attribute missing."); try { //string Metadata = Helpers.WebResponseHelper.GetWebResponse(String.Format("https://graph.facebook.com/{0}", FacebookID)); //MetadataJO = new JsonObject(Metadata); FacebookPage = new GraphApi.Page(FacebookID); if (_LikeBoxMode != LikeBoxMode.FeedOnly) OutputHeader(output); if (_LikeBoxMode != LikeBoxMode.HeaderOnly) OutputFeed(output); } catch (WebException ex) { output.Write(ex.Message); } //output.Write("</div>"); }
/// <summary> /// Render a RSS feed from a Facebook Page's Posts on its Wall /// </summary> /// <param name="context">HttpContext object</param> /// <param name="FacebookID">Page ID</param> public static void RenderRSSFeed(HttpContext context, string FacebookID) { string StringResponse = GetWebResponse(String.Format("https://graph.facebook.com/{0}/posts",FacebookID)); StringResponse = StringResponse.Replace("&", "&"); //string Metadata = GetWebResponse(String.Format("https://graph.facebook.com/{0}",FacebookID)); GraphApi.Page FacebookPage = new GraphApi.Page(FacebookID); JsonObject JO = new JsonObject(StringResponse); //JsonObject MetadataJO = new JsonObject(Metadata); context.Response.Clear(); context.Response.ContentType = "application/rss+xml"; //context.Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); context.Response.Write("<rss version=\"2.0\">"); context.Response.Write("<channel>"); context.Response.Write(WriteTag("title", FacebookPage.name)); context.Response.Write(WriteTag("link", FacebookPage.link)); context.Response.Write(WriteTag("description", "some description")); context.Response.Write(WriteTag("category", "link/photo/status/video")); if (FacebookPage.picture != null) { context.Response.Write("<image>"); context.Response.Write(WriteTag("url", FacebookPage.picture)); context.Response.Write(WriteTag("title", FacebookPage.name)); context.Response.Write(WriteTag("link", FacebookPage.link)); context.Response.Write("</image>"); } JsonArray Posts = (JsonArray)JO["data"]; foreach (JsonObject Post in Posts.JsonObjects) { context.Response.Write("\r\n"); context.Response.Write("<item>"); if (Post["name"] != null) context.Response.Write(WriteTag("title", (string)Post["name"])); else context.Response.Write(WriteTag("title", FacebookPage.name)); if (Post["link"] != null) context.Response.Write(WriteTag("link", (string)Post["link"])); else context.Response.Write(WriteTag("link", FacebookPage.link)); //description context.Response.Write("<description><![CDATA["); if (Post["picture"] != null) context.Response.Write(String.Format("<img src=\"{0}\" />", (string)Post["picture"])); context.Response.Write(WriteTag("p", (string)Post["message"])); if (Post["description"] != null) { context.Response.Write("<p style=\"color:#505050\">"); context.Response.Write((string)Post["description"]); context.Response.Write("</p>"); } context.Response.Write("]]></description>"); context.Response.Write(WriteTag("category", (string)Post["type"])); context.Response.Write(WriteTag("pubDate", Helpers.Generic.RFC3339ToDateTime((string)Post["created_time"]).ToString("d MMM yyyy HH:mm:ss"))); context.Response.Write("</item>"); } context.Response.Write("</channel>"); context.Response.Write("</rss>"); context.Response.End(); }