Example #1
0
        private void AddFacebookFeed(List <FeedItem> items, string sessionKey, DateTime dateContext)
        {
            try
            {
                // Get infinite session key
                ArrayList args = new ArrayList();
                args.Add("v=1.0");
                args.Add("api_key=" + MiscUtil.GetFacebookApiKey());
                args.Add("session_key=" + sessionKey);
                args.Add("method=photos.get");
                string subjectId = sessionKey.Split('-')[1];
                args.Add("subj_id=" + subjectId);
                XmlDocumentEx xmlDoc = MiscUtil.CallFacebook(args);
                xmlDoc.LoadNamespaces();

                foreach (XmlNode node in xmlDoc.SelectNodes("//dfltns:photo", xmlDoc.NamespaceManager))
                {
                    XmlNode source = node.SelectSingleNode("./dfltns:src_big", xmlDoc.NamespaceManager);
                    if (source == null)
                    {
                        source = node.SelectSingleNode("./dfltns:src", xmlDoc.NamespaceManager);
                    }
                    if (source == null)
                    {
                        source = node.SelectSingleNode("./dfltns:src_small", xmlDoc.NamespaceManager);
                    }
                    if (source != null)
                    {
                        string   imageUrl = source.InnerText;
                        uint     created  = Convert.ToUInt32(node.SelectSingleNode("./dfltns:created", xmlDoc.NamespaceManager).InnerText);
                        DateTime pubDate  = new System.DateTime(1970, 1, 1).AddSeconds(created);

                        int width  = -1;
                        int height = -1;

                        FeedItem feedItem = new FeedItem();
                        feedItem.pubDate     = pubDate;
                        feedItem.imageUrl    = imageUrl;
                        feedItem.imageWidth  = width;
                        feedItem.imageHeight = height;
                        items.Add(feedItem);
                    }
                }
            }
            catch (Exception)
            {
            }
        }