Пример #1
0
        List <JToken> GetGraphApiReplyUntillEnd(string url, string parms)
        {
            var replies = new List <JToken>();

            replies.Add(GetGraphApiReply(url, parms));
            while (Nullify.Get(replies.Last(), x => x["paging"], x => x["cursors"], x => x["after"]) != null)
            {
                var reply = GetGraphApiReply(url, parms + "&after=" + replies.Last()["paging"]["cursors"]["after"]);
                replies.Add(reply);
            }
            return(replies);
        }
Пример #2
0
        public List <Post> GetPosts(string page_fb_id, int lookbackDays, DateTime dateFrom)
        {
            var limit = ConfigurationManager.AppSettings["PagePostLimit"];
            var until = dateFrom;
            var since = until.AddDays(-lookbackDays);
            var obj   = GetGraphApiReply(page_fb_id + "/posts", "fields=id,message,created_time,shares&limit=" + limit + "&since=" + since.ToUnixTimestamp() + "&until=" + until.ToUnixTimestamp());

            var fb_posts = obj["data"].Where(x => x["message"] != null)
                           .Select(x =>
            {
                var shareElement = Nullify.Get(x, y => y["shares"], y => y["count"]);

                return(new Post
                {
                    message = x["message"].ToString(),
                    id = x["id"].ToString(),
                    date = JsonToTime(x["created_time"]),
                    shares = shareElement == null ? 0 : int.Parse(shareElement.ToString())
                });
            }).ToList();

            return(fb_posts);
        }