Example #1
0
        public static string ShareFeed(string fbAccesstoken, string FeedId, string pageId, string message, string fbUserId, string title, int time)
        {
            try
            {
                ShareathonRepository sharepo = new ShareathonRepository();
                Domain.Socioboard.Domain.SharethonPost objshrpost = new Domain.Socioboard.Domain.SharethonPost();
                string link = "https://www.facebook.com/" + pageId + "/posts/" + FeedId;

                FacebookClient fb = new FacebookClient();
                fb.AccessToken = fbAccesstoken;
                var args = new Dictionary <string, object>();

                args["message"]     = message;
                args["description"] = title;
                args["link"]        = link;
                if (!sharepo.IsPostExist(fbUserId, pageId, FeedId))
                {
                    dynamic output = fb.Post("v2.0/" + fbUserId + "/feed", args);
                    objshrpost.Id = Guid.NewGuid();
                    objshrpost.Facebookaccountid = fbUserId;
                    objshrpost.Facebookpageid    = pageId;
                    string feed_id = output["id"].ToString();
                    objshrpost.PostId     = FeedId;
                    objshrpost.PostedTime = DateTime.UtcNow;
                    sharepo.AddShareathonPost(objshrpost);
                }
            }
            catch (Exception ex)
            {
            }



            return("success");
        }
        public static string ShareFeed(string fbAccesstoken, string FeedId, string pageId, string message, string fbUserId,string FbPageName)
        {
            string ret = "";

            try
            {
                ShareathonRepository sharepo = new ShareathonRepository();
                Domain.Socioboard.Domain.SharethonPost objshrpost = new Domain.Socioboard.Domain.SharethonPost();
                string link = "https://www.facebook.com/" + pageId + "/posts/" + FeedId;
                
                FacebookClient fb = new FacebookClient();
                fb.AccessToken = fbAccesstoken;
                var args = new Dictionary<string, object>();

                args["message"] = message;
                args["link"] = link;
                if (!sharepo.IsPostExist(fbUserId, pageId, FeedId))
                {
                    try
                    {
                        dynamic output = fb.Post("v2.0/" + fbUserId + "/feed", args);
                        string feed_id = output["id"].ToString();
                        objshrpost.Id = Guid.NewGuid();
                        objshrpost.Facebookaccountid = fbUserId;
                        objshrpost.Facebookpageid = pageId;
                        objshrpost.PostId = FeedId;
                        objshrpost.PostedTime = DateTime.UtcNow;
                        objshrpost.Facebookpagename = FbPageName;
                        sharepo.AddShareathonPost(objshrpost);
                        ret = "success";
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex.StackTrace);
                        return "";
                    }
                    
                }

            }
            catch (Exception ex)
            {

            }



            return ret;
        }