public string GetInstagramUserPosts(string profile_id, string access_token)
        {
            string code_status = "false";
            Domain.Socioboard.Domain.InstagramSelfFeed send_data = new Domain.Socioboard.Domain.InstagramSelfFeed();
            string url = "https://api.instagram.com/v1/users/" + profile_id + "/media/recent?access_token=" + access_token;
            try
            {
                JObject post_data = JObject.Parse(ApiInstagramHttp(url));

                try
                {
                    dynamic items = post_data["data"];
                    foreach (var item in items)
                    {
                        Guid Id = Guid.NewGuid();

                        string post_url = string.Empty;
                        string feed_url = string.Empty;
                        string user_name = string.Empty;
                        string type = item["type"].ToString();
                        string feed_id = item["id"].ToString();
                        string created_time = item["created_time"].ToString();
                        DateTime create_time = DateExtension.ToDateTime(DateTime.Now, long.Parse(created_time));
                        if (create_time.Date >= DateTime.Now.AddDays(-90).Date)
                        {
                            if (type.Equals("video"))
                            {
                                try
                                {
                                    post_url = item["videos"]["standard_resolution"]["url"].ToString();
                                    feed_url = item["link"].ToString();
                                    user_name = item["user"]["username"].ToString();
                                }
                                catch (Exception)
                                {
                                }

                            }
                            else if (type.Equals("image"))
                            {
                                try
                                {
                                    post_url = item["images"]["standard_resolution"]["url"].ToString();
                                    feed_url = item["link"].ToString();
                                    user_name = item["user"]["username"].ToString();
                                }
                                catch (Exception)
                                {
                                }
                            }

                            send_data.Id = Id;
                            send_data.User_name = user_name;
                            send_data.ProfileId = profile_id;
                            send_data.FeedId = feed_id;
                            send_data.Accesstoken = access_token;
                            send_data.Post_url = post_url;
                            send_data.Link = feed_url;
                            send_data.Type = type;
                            send_data.Created_Time = create_time;
                            //string i = new JavaScriptSerializer().Serialize(send_data);
                            insertdata(send_data);
                            code_status = "true";
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }

                try
                {
                    dynamic pagination_url = post_data["pagination"];

                    string next_url = string.Empty;

                    if (pagination_url != null)
                    {
                        try
                        {
                            next_url = post_data["pagination"]["next_url"].ToString();
                        }
                        catch (Exception)
                        {
                            pagination_url = null;
                        }
                        while (pagination_url != null)
                        {
                            JObject post_data_next = JObject.Parse(ApiInstagramHttp(next_url));
                            try
                            {
                                next_url = post_data_next["pagination"]["next_url"].ToString();
                                pagination_url = post_data_next["pagination"];
                            }
                            catch (Exception)
                            {
                                pagination_url = null;
                            }
                            try
                            {
                                dynamic items_next = post_data_next["data"];
                                foreach (var item in items_next)
                                {
                                    Guid Id = Guid.NewGuid();
                                    string post_url = string.Empty;
                                    string feed_url = string.Empty;
                                    string user_name = string.Empty;
                                    string feed_id = item["id"].ToString();
                                    string type = item["type"].ToString();
                                    string created_time = item["created_time"].ToString();
                                    DateTime create_time = DateExtension.ToDateTime(DateTime.Now, long.Parse(created_time));
                                    if (create_time.Date >= DateTime.Now.AddDays(-90).Date)
                                    {
                                        if (type.Equals("video"))
                                        {
                                            try
                                            {
                                                post_url = item["videos"]["standard_resolution"]["url"].ToString();
                                                feed_url = item["link"].ToString();
                                                user_name = item["user"]["username"].ToString();
                                            }
                                            catch (Exception)
                                            {
                                            }
                                        }
                                        else if (type.Equals("image"))
                                        {
                                            try
                                            {
                                                post_url = item["images"]["standard_resolution"]["url"].ToString();
                                                feed_url = item["link"].ToString();
                                                user_name = item["user"]["username"].ToString();
                                            }
                                            catch (Exception)
                                            {
                                            }
                                        }
                                        send_data.Id = Id;
                                        send_data.User_name = user_name;
                                        send_data.ProfileId = profile_id;
                                        send_data.FeedId = feed_id;
                                        send_data.Accesstoken = access_token;
                                        send_data.Post_url = post_url;
                                        send_data.Link = feed_url;
                                        send_data.Type = type;
                                        send_data.Created_Time = create_time;
                                        //string i = new JavaScriptSerializer().Serialize(send_data);
                                        insertdata(send_data);
                                        code_status = "true";
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                }
            }
            catch (Exception ex)
            {

            }
            return code_status;
        }
        public string GetInstagramPostLikes(string profile_id, string access_token, int status)
        {
            string code_status = "false";
            Domain.Socioboard.Domain.InstagramPostLikes insert = new Domain.Socioboard.Domain.InstagramPostLikes();
            JObject post_data = new JObject();
            string url = "https://api.instagram.com/v1/users/" + profile_id + "/media/recent?access_token=" + access_token + "&count=30";
            try
            {
                post_data = JObject.Parse(ApiInstagramHttp(url));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            try
            {
                dynamic items = post_data["data"];
                foreach (var item in items)
                {
                    string post_url = string.Empty;
                    string feed_url = string.Empty;
                    string user_name = string.Empty;
                    Guid Id = Guid.NewGuid();
                    string feed_id = item["id"].ToString();
                    string feed_type = item["type"].ToString();
                    string created_time_feed = item["created_time"].ToString();
                    DateTime create_time_feed = DateExtension.ToDateTime(DateTime.Now, long.Parse(created_time_feed));

                    Domain.Socioboard.Domain.InstagramSelfFeed send_data = new Domain.Socioboard.Domain.InstagramSelfFeed();

                    try
                    {
                        if (feed_type.Equals("video"))
                        {
                            try
                            {
                                post_url = item["videos"]["standard_resolution"]["url"].ToString();
                                feed_url = item["link"].ToString();
                                user_name = item["user"]["username"].ToString();
                            }
                            catch (Exception)
                            {
                            }

                        }
                        else if (feed_type.Equals("image"))
                        {
                            try
                            {
                                post_url = item["images"]["standard_resolution"]["url"].ToString();
                                feed_url = item["link"].ToString();
                                user_name = item["user"]["username"].ToString();
                            }
                            catch (Exception)
                            {
                            }
                        }

                        send_data.Id = Id;
                        send_data.User_name = user_name;
                        send_data.ProfileId = profile_id;
                        send_data.FeedId = feed_id;
                        send_data.Accesstoken = access_token;
                        send_data.Post_url = post_url;
                        send_data.Link = feed_url;
                        send_data.Type = feed_type;
                        send_data.Created_Time = create_time_feed;
                        //string i = new JavaScriptSerializer().Serialize(send_data);
                        insertdata(send_data);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }



                    try
                    {
                        dynamic likes = item["likes"]["data"];
                        foreach (var like in likes)
                        {
                            try
                            {
                                string liked_by_id = like["id"].ToString();
                                string liked_by_name = like["username"].ToString();
                                insert.Id = Id;
                                insert.Profile_Id = profile_id;
                                insert.Feed_Id = feed_id;
                                insert.Liked_By_Id = liked_by_id;
                                insert.Liked_By_Name = liked_by_name;
                                insert.Feed_Type = feed_type;
                                insert.Created_Date = DateTime.Now;
                                insert.Status = status;
                                //string i = new JavaScriptSerializer().Serialize(insert);
                                insertpostlikes(insert);
                                code_status = "true";
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }

                }
            }
            //}
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            //try
            //{
            //    dynamic pagination_url = post_data["pagination"];
            //    string next_url = string.Empty;
            //    if (pagination_url != null)
            //    {
            //        try
            //        {
            //            next_url = post_data["pagination"]["next_url"].ToString();
            //        }
            //        catch (Exception)
            //        {
            //            pagination_url = null;
            //        }
            //        while (pagination_url != null)
            //        {
            //            JObject post_data_next = JObject.Parse(ApiInstagramHttp(next_url));
            //            try
            //            {
            //                next_url = post_data_next["pagination"]["next_url"].ToString();
            //                pagination_url = post_data_next["pagination"];
            //            }
            //            catch (Exception)
            //            {
            //                pagination_url = null;
            //            }
            //            try
            //            {
            //                dynamic items_next = post_data_next["data"];
            //                foreach (var item in items_next)
            //                {
            //                    Guid Id = Guid.NewGuid();
            //                    string feed_id = item["id"].ToString();
            //                    string feed_type = item["type"].ToString();
            //                    string created_time_feed = item["created_time"].ToString();
            //                    DateTime create_time_feed = DateExtension.ToDateTime(DateTime.Now, long.Parse(created_time_feed));

            //                    //if (create_time_feed.Date >= DateTime.Now.AddDays(-90).Date)
            //                    //{
            //                    try
            //                    {
            //                        dynamic likes = item["likes"]["data"];
            //                        foreach (var like in likes)
            //                        {
            //                            try
            //                            {
            //                                string liked_by_id = like["id"].ToString();
            //                                string liked_by_name = like["username"].ToString();
            //                                insert.Id = Id;
            //                                insert.Profile_Id = profile_id;
            //                                insert.Feed_Id = feed_id;
            //                                insert.Liked_By_Id = liked_by_id;
            //                                insert.Liked_By_Name = liked_by_name;
            //                                insert.Feed_Type = feed_type;
            //                                //string i = new JavaScriptSerializer().Serialize(insert);
            //                                insertpostlikes(insert);
            //                                code_status = "true";
            //                            }
            //                            catch (Exception ex)
            //                            {
            //                                logger.Error(ex.Message);
            //                            }
            //                        }
            //                    }
            //                    catch (Exception ex)
            //                    {
            //                        logger.Error(ex.Message);
            //                    }
            //                }
            //            }
            //            //}
            //            catch (Exception ex)
            //            {
            //                logger.Error(ex.Message);
            //            }
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    logger.Error(ex.Message);
            //}

            return code_status;

        }