예제 #1
0
        public static void postfeedGroup(string fbaccesstoken, string fbgrpids, string feedid, string facebookaccountid, int time)
        {
            List <string>             lstPost   = new List <string>();
            int                       lstCout   = 0;
            bool                      isPosted  = false;
            ShareathonGroupRepository shareagrp = new ShareathonGroupRepository();

            Domain.Socioboard.Domain.SharethonGroupPost objshrgrp = new Domain.Socioboard.Domain.SharethonGroupPost();
            FacebookClient fb = new FacebookClient();

            string[] postid = feedid.TrimEnd(',').Split(',');
            fb.AccessToken = fbaccesstoken;
            Random r      = new Random();
            int    length = postid.Length;

            while (length != lstCout)
            {
                int i = r.Next(0, length - 1);

                if (!lstPost.Contains(postid[i]))
                {
                    lstPost.Add(postid[i]);
                    lstCout++;


                    string[] group = fbgrpids.Split(',');
                    foreach (var item in group)
                    {
                        isPosted = shareagrp.IsPostExist(item, postid[i], facebookaccountid);
                        if (!isPosted)
                        {
                            string link = "https://www.facebook.com/" + postid[i];
                            var    args = new Dictionary <string, object>();

                            args["link"] = link;
                            try
                            {
                                dynamic output = fb.Post("v2.0/" + item + "/feed", args);
                            }
                            catch (Exception ex)
                            {
                                Console.Write(ex.StackTrace);
                            }
                            objshrgrp.Id = Guid.NewGuid();
                            objshrgrp.Facebookaccountid = facebookaccountid;
                            objshrgrp.Facebookgroupid   = item;
                            objshrgrp.PostId            = postid[i];
                            objshrgrp.PostedTime        = DateTime.UtcNow;
                            shareagrp.AddShareathonPost(objshrgrp);

                            Thread.Sleep(1000 * 15);
                        }
                    }

                    Thread.Sleep(1000 * 60 * time);
                }
            }
        }
예제 #2
0
        public static string ShareFeedonGroup(string fbAccesstoken, string FeedId, string pageId, string message, string fbgroupId, string title, int time, string faceaccountId)
        {
            string[] feedid = FeedId.TrimEnd(',').Split(',');

            string[] grpid = fbgroupId.Split(',');
            for (int i = 0; i < feedid.Length; i++)
            {
                try
                {
                    ShareathonGroupRepository shareagrp = new ShareathonGroupRepository();
                    Domain.Socioboard.Domain.SharethonGroupPost objshrgrp = new Domain.Socioboard.Domain.SharethonGroupPost();
                    string link = "https://www.facebook.com/" + feedid[i];

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


                    args["message"]     = message;
                    args["description"] = title;
                    args["link"]        = link;
                    foreach (var item in grpid)
                    {
                        new Thread(delegate()
                        {
                            PostGroupMultiple(item, time, faceaccountId, feedid, i, shareagrp, objshrgrp, fb, args);
                        });
                        Thread.Sleep(1000 * 15);
                    }
                }
                catch (Exception ex)
                {
                }
            }


            return("success");
        }
예제 #3
0
 private static void PostGroupMultiple(string fbgroupId, int time, string faceaccountId, string[] feedid, int i, ShareathonGroupRepository shareagrp, Domain.Socioboard.Domain.SharethonGroupPost objshrgrp, FacebookClient fb, Dictionary <string, object> args)
 {
     if (!shareagrp.IsPostExist(fbgroupId, feedid[i], faceaccountId))
     {
         try
         {
             dynamic output = fb.Post("v2.0/" + fbgroupId + "/feed", args);
         }
         catch (Exception ex)
         {
             Console.Write(ex.StackTrace);
         }
         objshrgrp.Id = Guid.NewGuid();
         objshrgrp.Facebookaccountid = faceaccountId;
         objshrgrp.Facebookgroupid   = fbgroupId;
         objshrgrp.PostId            = feedid[i];
         shareagrp.AddShareathonPost(objshrgrp);
         Thread.Sleep(1000 * 60 * time);
     }
 }