public JsonResult TwitterSendDirectMessage()
        {
            bool result = false;

            string _consumerKey = System.Configuration.ConfigurationManager.AppSettings["consumerKeyLogin"];
            string _consumerSecret = System.Configuration.ConfigurationManager.AppSettings["consumerSecretLogin"];
            TwitterService service = new TwitterService(_consumerKey, _consumerSecret);

            service.AuthenticateWith(Session[Sessionvars.TwitterRequestToken].ToString(), Session[Sessionvars.TwitterRequestTokenSecert].ToString());
            string TwitterDirectMessage = Request.Params["TwitterDM"];

            string ListSelectUserDM = Convert.ToString(Request.Params["SelectedUserForDM"]);
            char[] splitchars = { ',' };
            string[] DirectMessageUserId = ListSelectUserDM.Split(splitchars, StringSplitOptions.RemoveEmptyEntries);
            if (DirectMessageUserId.Count() > 0)
            {
                foreach (var list in DirectMessageUserId)
                {
                    TwitterDirectMessage Ds = service.SendDirectMessage(Convert.ToInt32(list), TwitterDirectMessage);
                }
                result = true;
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        public void Send(ChannelMessage message)
        {
            var service = new TwitterService(ChannelHelper.ConsumerKey, ChannelHelper.ConsumerSecret, ChannelHelper.Token, ChannelHelper.TokenSecret);

            foreach (var singleToName in message.To)
            {
                service.SendDirectMessage(Int32.Parse(singleToName.Address), message.BodyText.ReadString());
            }
        }
Exemple #3
0
        public ActionResult TweetRequest(int[] Id)
        {
            if (OAuthWebSecurity.IsAuthenticatedWithOAuth)
            {
                ContextDb _db = new ContextDb();
                Models.Service service = _db.User.FirstOrDefault(c => c.UserId == WebSecurity.CurrentUserId).Services.FirstOrDefault(c => c.Provider == "twitter");
                if (service != null)
                {
                    TwitterService twitter = new TwitterService(Settings.Settings.TwitterConsumerKey, Settings.Settings.TwitterConsumerSecret, service.Token, service.TokenSecret);
                    foreach (var item in Id)
                    {
                        twitter.SendDirectMessage(item, "Join us at www.botf.azurewebsites.net");
                    }

                }
            }

            return RedirectToAction("Index");
        }
Exemple #4
0
        public static void SendTweet_Start(string sMessage, int userID)
        {
            // alpascual
            // Pass your credentials to the service
            TwitterService service = new TwitterService("yASjbX9Zbu1OD0gk89qExA", "mTDH5xPm6Fu1KS3m1NUVTWKXBXi330TCakspt5Dz060");
            //OAuthAccessToken access = service.GetAccessTokenWithXAuth("alpascual", ""); // <-- user supplied username and password

            //// Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            //// Step 2 - Redirect to the OAuth Authorization URL
            Uri uri = service.GetAuthorizationUri(requestToken);
            ////Process.Start(uri.ToString());
            //WebClient client = new WebClient();
            //string sResponse = client.DownloadString(uri);

            //// Step 3 - Exchange the Request Token for an Access Token
            string verifier = "3479615"; // <-- This is input into your application by your user
            OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(access.Token, access.TokenSecret);

            if (userID == 0)
            {
                TwitterStatus status = service.SendTweet(sMessage);
            }
            else
                service.SendDirectMessage(userID, sMessage);
        }