コード例 #1
0
        public static bool TryPostMessageToFacebook(PostMessage message)
        {
            try
            {
                var ChromeWebDriver = GetDriver();
                ChromeWebDriver.Navigate().GoToUrl("https://www.facebook.com/TP-1996120520653285/inbox/?selected_item_id=100002948674558");
                Thread.Sleep(2000);
                //  ChromeWebDriver.Navigate().GoToUrl("https://www.facebook.com/pages/?category=your_pages");
                string pageSource = ChromeWebDriver.PageSource;


                ReadOnlyCollection <IWebElement> writeNode =
                    ChromeWebDriver.FindElements(By.XPath("//*[@placeholder='Write a reply...']"));
                if (writeNode.Count > 0)
                {
                    Thread.Sleep(2000);
                    writeNode[0].SendKeys(message.Message);
                    Thread.Sleep(2000);
                }

                ReadOnlyCollection <IWebElement> submitnode =
                    ChromeWebDriver.FindElements(By.XPath("//*[@type='submit']"));
                if (submitnode.Count > 0)
                {
                    Thread.Sleep(2000);
                    submitnode[1].Click();
                    Thread.Sleep(2000);
                }
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
コード例 #2
0
        public static bool TryPostImageToFacebook(PostMessage message)
        {
            try
            {
                var ChromeWebDriver = GetDriver();
                ReadOnlyCollection <IWebElement> emailElement1 = ChromeWebDriver.FindElements(By.ClassName("UFICommentPhotoIcon"));
                if (emailElement1.Count > 0)
                {
                    emailElement1[0].Click();
                }
                Thread.Sleep(3000);

                ReadOnlyCollection <IWebElement> sendimage = ChromeWebDriver.FindElements(By.XPath(".//span[@data-testid='ufi_photo_preview_test_id']"));
                if (sendimage.Count > 0)
                {
                    Thread.Sleep(3000);
                    sendimage[0].SendKeys(Keys.Enter);
                    Thread.Sleep(3000);
                }
            }
            catch (Exception)
            {
                // ;
            }
            return(false);
        }
コード例 #3
0
        public bool TryPostMessageToInsta(PostMessage message)
        {
            var    ChromeWebDriver = GetDriver();
            string url             = message.ToUrl;

            ChromeWebDriver.Navigate().GoToUrl(url);
            OnlineFetcher.SetCookies(ChromeWebDriver);
            ChromeWebDriver.Navigate().GoToUrl(url);

            Thread.Sleep(3000);
            var emailElement = ChromeWebDriver.FindElements(By.XPath("//input[@class='_58al']"));

            if (emailElement.Count > 0)
            {
                Thread.Sleep(3000);
                emailElement[0].SendKeys(message.Message);
            }
            Thread.Sleep(3000);
            var sendmessage = ChromeWebDriver.FindElements(By.XPath("//div[@class='_1fn8 _45dg']"));

            //ReadOnlyCollection<IWebElement> sendmessage = _chromeWebDriver.FindElements(By.ClassName("input"));
            if (sendmessage.Count > 0)
            {
                sendmessage[0].Click();
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public bool TryPostImageToFBMessenger(PostMessage message)
        {
            var    ChromeWebDriver = GetDriver();
            string url             = message.ToUrl;

            ChromeWebDriver.Navigate().GoToUrl(url);
            OnlineFetcher.SetCookies(ChromeWebDriver);
            ChromeWebDriver.Navigate().GoToUrl(url);

            Thread.Sleep(5000);

            var maincontainer = ChromeWebDriver.FindElement(By.XPath("//input[@name='attachment[]']"));

            if (maincontainer != null)
            {
                maincontainer.SendKeys("C:/Users/Lenovo/Downloads/2878030-128.png");
            }
            var maincontainersend = ChromeWebDriver.FindElement(By.XPath("//div[@class='_4dw3']"));

            if (maincontainersend != null)
            {
                Thread.Sleep(2000);
                maincontainersend.Click();
                return(true);
            }
            return(false);
        }
コード例 #5
0
        public bool TryPostMessageToFacebook(PostMessage message)
        {
            var ChromeWebDriver = GetDriver();

            string url = message.ToUrl;

            ChromeWebDriver.Navigate().GoToUrl(url);
            OnlineFetcher.SetCookies(ChromeWebDriver);
            ChromeWebDriver.Navigate().GoToUrl(url);
            Thread.Sleep(2000);
            ReadOnlyCollection <IWebElement> postcomment = ChromeWebDriver.FindElements(By.XPath("//*[@class='UFICommentContainer']"));

            if (postcomment.Count > 0)
            {
                postcomment[0].Click();
                ReadOnlyCollection <IWebElement> postcomghghment = ChromeWebDriver.FindElements(By.XPath("//*[@class='notranslate _5rpu']"));
                if (postcomghghment.Count > 0)
                {
                    postcomghghment[0].SendKeys(message.Message);
                    Thread.Sleep(3000);
                    postcomghghment[0].SendKeys(OpenQA.Selenium.Keys.Enter);
                    return(true);
                }
            }
            return(false);
        }
コード例 #6
0
        //
        //public void ProcessMessage()
        //{
        //    PostMessage message;
        //    try
        //    {
        //        if (_producerConsumerCollection.TryPeek(out message))
        //        {
        //            if (TryMessagePosting(message))
        //            {
        //                _producerConsumerCollection.TryDequeue(out message);
        //            }
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        //Log message
        //    }
        //    finally
        //    {
        //        RestartThread();
        //    }

        //}

        //private void RestartThread()
        //{
        //    System.Threading.Thread thread;
        //    thread = new System.Threading.Thread(ProcessMessage);
        //    thread.Start();
        //}

        private bool TryMessagePosting(PostMessage message)
        {
            try {
                switch (message.MessageTypeResponse)
                {
                case 1:
                    return(TryPostMessageToFacebook(message));

                case 2:
                    return(TryPostImageToFacebook(message));

                case 3:
                    return(TryPostMessageToInsta(message));

                case 4:
                    return(TryPostMessageToFBMessenger(message));

                case 5:
                    return(TryPostImageToFBMessenger(message));

                default:
                    return(false);
                }
            }
            catch (Exception ex) {
            }
            return(true);
        }
コード例 #7
0
 public bool TryPostImageToFacebook(PostMessage message)
 {
     try
     {
         var    ChromeWebDriver = GetDriver();
         string url             = message.ToUrl;
         ChromeWebDriver.Navigate().GoToUrl(url);
         OnlineFetcher.SetCookies(ChromeWebDriver);
         ChromeWebDriver.Navigate().GoToUrl(url);
         Thread.Sleep(4000);
         ReadOnlyCollection <IWebElement> emailElement1 = ChromeWebDriver.FindElements(By.ClassName("UFICommentPhotoIcon"));
         if (emailElement1.Count > 0)
         {
             emailElement1[0].Click();
         }
         Thread.Sleep(15000);
         ReadOnlyCollection <IWebElement> sendimage = ChromeWebDriver.FindElements(By.XPath(".//div[@class='notranslate _5rpu']"));
         if (sendimage.Count > 0)
         {
             sendimage[0].Click();
             Thread.Sleep(3000);
             sendimage[0].SendKeys(Keys.Enter);
             Thread.Sleep(3000);
         }
     }
     catch (Exception)
     {
     }
     return(false);
 }
コード例 #8
0
        public bool TryPostImageToFBMessenger(PostMessage message)
        {
            var    ChromeWebDriver = GetDriver();
            string url             = message.ToUrl;

            ChromeWebDriver.Navigate().GoToUrl(url);
            OnlineFetcher.SetCookies(ChromeWebDriver);
            ChromeWebDriver.Navigate().GoToUrl(url);

            ReadOnlyCollection <IWebElement> emailElement = ChromeWebDriver.FindElements(By.ClassName("_4dvy"));

            if (emailElement.Count > 0)
            {
                emailElement[0].Click();
            }
            Thread.Sleep(7000);

            ReadOnlyCollection <IWebElement> sendimage = ChromeWebDriver.FindElements(By.ClassName("_4dw3"));

            if (sendimage.Count > 0)
            {
                Thread.Sleep(3000);
                sendimage[0].Click();
                Thread.Sleep(3000);
            }
            return(false);
        }
コード例 #9
0
 public void Add(PostMessage message)
 {
     //ObservableCollection<FbUserMessageInfo> messagingListInfo = new ObservableCollection<FbUserMessageInfo>();
     var    sql   = GetSqliteHelper();
     string query = "INSERT INTO Jobs(FromUserId,ToUserId, Message,ImagePath,MessageType,PlateformType,Status,ToUrl) values('" + message.FromUserId + "','" + message.ToUserId + "','" + message.Message + "','" + message.ImagePath + "','" + (int)message.MessageType + "','" + "1" + "','0','" + message.ToUrl + "')";
     int    yy    = sql.ExecuteNonQuery(query);
 }
コード例 #10
0
        public bool TryPostImageToFacebook(PostMessage message)
        {
            try
            {
                var    ChromeWebDriver = GetDriver();
                string url             = message.ToUrl;
                ChromeWebDriver.Navigate().GoToUrl(url);
                OnlineFetcher.SetCookies(ChromeWebDriver);
                ChromeWebDriver.Navigate().GoToUrl(url);
                Thread.Sleep(4000);

                var maincontainer = ChromeWebDriver.FindElementByXPath("//div[@class='tickerDialogFooter']");

                if (maincontainer != null)
                {
                    maincontainer = ChromeWebDriver.FindElementByClassName("UFICommentPhotoIcon");
                    ((IJavaScriptExecutor)ChromeWebDriver).ExecuteScript("HTMLInputElement.prototype.click = function() {" + "  if(input.type !== 'file') HTMLElement.prototype.click.call(this); " + "}; ");
                    //Thread.Sleep(5000);
                    maincontainer.Click();

                    ((IJavaScriptExecutor)ChromeWebDriver).ExecuteScript("HTMLInputElement.prototype.click = function() {" + "  if(input.type !== 'file') HTMLElement.prototype.click.call(this); " + "}; ");
                    var maincontai = ChromeWebDriver.FindElementByXPath("//input[@type='file']");

                    maincontainer = ChromeWebDriver.FindElementByXPath("//input[@type='file']");
                    maincontainer.SendKeys(message.ImagePath);
                    Thread.Sleep(2000);
                }
                var maincontainersend = ChromeWebDriver.FindElement(By.XPath("//div[@class='_5rp7']"));
                if (maincontainersend != null)
                {
                    maincontainersend.Click();
                    Thread.Sleep(2000);
                    //SendKeys.SendWait(@"{ENTER}");
                    maincontainersend.SendKeys(Keys.Enter);
                }
            }
            catch (Exception)
            {
            }
            return(false);
        }
コード例 #11
0
        public static bool TryPostMessageToFBMessenger(PostMessage message)
        {
            var ChromeWebDriver = GetDriver();
            ReadOnlyCollection <IWebElement> emailElement = ChromeWebDriver.FindElements(By.ClassName("_4dvy"));

            if (emailElement.Count > 0)
            {
                emailElement[0].Click();
            }
            Thread.Sleep(3000);

            ReadOnlyCollection <IWebElement> sendimage = ChromeWebDriver.FindElements(By.ClassName("_4dw3"));

            if (sendimage.Count > 0)
            {
                Thread.Sleep(3000);
                sendimage[0].Click();
                Thread.Sleep(3000);
            }
            return(false);
        }
コード例 #12
0
        public static bool TryPostMessageToInsta(PostMessage message)
        {
            var ChromeWebDriver = GetDriver();

            // string url = "https://www.facebook.com/TP-1996120520653285/inbox/?selected_item_id=1996233970641940";
            //    ChromeWebDriver.Navigate().GoToUrl(url);
            Thread.Sleep(2000);
            ReadOnlyCollection <IWebElement> postcomment = ChromeWebDriver.FindElements(By.XPath("//*[@class='UFICommentContainer']"));

            if (postcomment.Count > 0)
            {
                postcomment[0].Click();
                ReadOnlyCollection <IWebElement> postcomghghment = ChromeWebDriver.FindElements(By.XPath("//*[@class='notranslate _5rpu']"));
                if (postcomghghment.Count > 0)
                {
                    postcomghghment[0].SendKeys(message.Message);
                    Thread.Sleep(1000);
                    postcomghghment[0].SendKeys(OpenQA.Selenium.Keys.Enter);
                }
            }
            return(false);
        }
コード例 #13
0
        public bool TryPostMessageToFBMessenger(PostMessage message)
        {
            try
            {
                var    chromeWebDriver = GetDriver();
                string url             = message.ToUrl;
                chromeWebDriver.Navigate().GoToUrl(url);
                OnlineFetcher.SetCookies(chromeWebDriver);
                chromeWebDriver.Navigate().GoToUrl(url);
                Thread.Sleep(5000);


                ReadOnlyCollection <IWebElement> writeNode =
                    chromeWebDriver.FindElements(By.XPath("//*[@placeholder='Write a reply...']"));
                if (writeNode.Count > 0)
                {
                    Thread.Sleep(4000);
                    writeNode[0].SendKeys(message.Message);
                    Thread.Sleep(4000);
                }
                ReadOnlyCollection <IWebElement> submitnode =
                    chromeWebDriver.FindElements(By.XPath("//*[@type='submit']"));
                if (submitnode.Count > 0)
                {
                    Thread.Sleep(3000);
                    submitnode[1].Click();
                    Thread.Sleep(2000);

                    return(true);
                }
            }
            catch (Exception)
            {
            }



            return(false);
        }
コード例 #14
0
        private static bool TryMessagePosting(PostMessage message)
        {
            switch (message.MessageType)
            {
            case MessageType.FacebookMessage:
                return(TryPostMessageToFacebook(message));

            case MessageType.FacebookImage:
                return(TryPostImageToFacebook(message));

            case MessageType.InstaMessage:
                return(TryPostMessageToInsta(message));

            case MessageType.FacebookMessengerMessage:
                return(TryPostMessageToFBMessenger(message));

            case MessageType.FacebookMessengerImage:
                return(TryPostImageToFBMessenger(message));

            default:
                return(false);
            }
        }
コード例 #15
0
 public static void Add(PostMessage message)
 {
     _producerConsumerCollection.Enqueue(message);
 }
コード例 #16
0
 public static bool TryPostImageToFBMessenger(PostMessage message)
 {
     return(false);
 }