Esempio n. 1
0
        /// <summary>
        /// Initializes the command.
        /// </summary>
        public override void Init()
        {
            this.RequestParameters.Add("status", this.Text);
            this.RequestParameters.Add("media[]", this.File);

            StatusUpdateOptions options = this.OptionalProperties as StatusUpdateOptions;

            if (options != null)
            {
                if (options.InReplyToStatusId > 0)
                {
                    this.RequestParameters.Add("in_reply_to_status_id", options.InReplyToStatusId.ToString(CultureInfo.CurrentCulture));
                }

                if (options.Latitude != 0)
                {
                    this.RequestParameters.Add("lat", options.Latitude.ToString());
                }

                if (options.Longitude != 0)
                {
                    this.RequestParameters.Add("long", options.Longitude.ToString());
                }

                if (!string.IsNullOrEmpty(options.PlaceId))
                {
                    this.RequestParameters.Add("place_id", options.PlaceId);
                }

                if (options.PlacePin)
                {
                    this.RequestParameters.Add("display_coordinates", "true");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Replies to the specified status.
        /// </summary>
        /// <param name="replyTo">A status that replies to.</param>
        /// <param name="status">A new status text.</param>
        public void Reply(TwitterStatus replyTo, string status)
        {
            var option = new StatusUpdateOptions()
            {
                InReplyToStatusId = replyTo.Id
            };

            Post(string.Format("@{0} {1}", replyTo.User.ScreenName, status), option);
        }
Esempio n. 3
0
 /// <summary>
 /// Posts the new status with the specified options.
 /// </summary>
 /// <param name="status">A new status text.</param>
 /// <param name="option">An option for updating status.</param>
 void Post(string status, StatusUpdateOptions option)
 {
     if (option == null)
     {
         TwitterStatus.Update(token, status);
     }
     else
     {
         TwitterStatus.Update(token, status, option);
     }
 }
Esempio n. 4
0
            public void unfavorite(decimal Id)
            {
                StatusUpdateOptions options = new StatusUpdateOptions();

                Twitterizer.TwitterResponse <TwitterStatus> response = Twitterizer.TwitterFavorite.Delete(privOAuth.GetOAuthToken(), Id);
                if (!(response.Result == RequestResult.Success))
                {
                    //throw new Exception("unfav failed: " + response.ErrorMessage);
                    System.Windows.Forms.MessageBox.Show("error: " + response.ErrorMessage, "error, unfav failed", System.Windows.Forms.MessageBoxButtons.OK);
                }
            }
Esempio n. 5
0
            public void Reply(decimal Id, string tweet)
            {
                StatusUpdateOptions options = new StatusUpdateOptions();

                options.InReplyToStatusId = Id;
                Twitterizer.TwitterResponse <TwitterStatus> response = Twitterizer.TwitterStatus.Update(privOAuth.GetOAuthToken(), tweet, options);
                if (!(response.Result == RequestResult.Success))
                {
                    //throw new Exception("reply failed: " + response.ErrorMessage);
                    System.Windows.Forms.MessageBox.Show("error: " + response.ErrorMessage, "error", System.Windows.Forms.MessageBoxButtons.OK);
                }
            }
Esempio n. 6
0
 public string sendTweet(string tweet, OAuthTokens tokens)
 {
     StatusUpdateOptions options = new StatusUpdateOptions() { UseSSL = true, APIBaseAddress = "http://api.twitter.com/1.1/" };
         TwitterResponse<TwitterStatus> response = TwitterStatus.Update(tokens, tweet, options);
         if (response.Result == RequestResult.Success)
         {
             return "bueno ";
         }
         else
         {
             return "malo ";
         }
 }
        public static void UpdateAndDelete()
        {
            OAuthTokens tokens = Configuration.GetTokens();

            StatusUpdateOptions options = new StatusUpdateOptions();

            TwitterStatus newStatus = TwitterStatus.Update(tokens, "Performing Twitterizer testing ...", options).ResponseObject;

            Assert.That(newStatus.Id > 0);

            TwitterStatus deletedStatus = newStatus.Delete(tokens).ResponseObject;

            Assert.That(newStatus.Id == deletedStatus.Id);
        }
Esempio n. 8
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            buttonUpdate.Enabled = false;
            textTweet.Enabled    = false;
            checkMedia.Enabled   = false;

            string strTweet = textTweet.Text.Replace("\r", "");

            if (strTweet[0] == 'D')
            {
                string[] astrDMParts = strTweet.Split(new char[] { ' ' }, 3);
                if (astrDMParts.Length == 3 && astrDMParts[0] == "D")
                {
                    TwitterDirectMessageAsync.Send(Global.requestToken, astrDMParts[1], astrDMParts[2], null, TimeSpan.FromSeconds(30), (TwitterAsyncResponse <TwitterDirectMessage> ee) => {
                        if (ee.ResponseObject == null)
                        {
                            TweetFailure(ee.Content);
                            return;
                        }

                        // NOTE: This is not required, as it comes in with streaming. I don't know why. Seriously, what?
                        //InsertDMIn(ee.ResponseObject, ColumnType.DirectMessages);

                        this.Invoke(new Action(delegate
                        {
                            textTweet.Enabled = true;
                            textTweet.Text    = "";
                            textTweet.Focus();

                            buttonUpdate.Enabled = true;
                        }));
                    });
                    return;
                }
            }

            StatusUpdateOptions sup = new StatusUpdateOptions();

            sup.InReplyToStatusId = tw_idInReplyTo;

            if (tw_strMediaFilename != "")
            {
                TwitterStatusAsync.UpdateWithMedia(Global.requestToken, strTweet, tw_strMediaFilename, TimeSpan.FromSeconds(30), UpdateResponse, sup);
            }
            else
            {
                TwitterStatusAsync.Update(Global.requestToken, strTweet, sup, TimeSpan.FromSeconds(30), UpdateResponse);
            }
        }
Esempio n. 9
0
        public static void TwitteStatus(String message)
        {
            OAuthTokens         tokens  = Configuration.GetTokens();
            StatusUpdateOptions options = new StatusUpdateOptions();

            var response = TwitterAccount.VerifyCredentials(tokens, new VerifyCredentialsOptions
            {
                IncludeEntities = true,
                UseSSL          = true
            });



            TwitterStatus newStatus = TwitterStatus.Update(tokens, message, options).ResponseObject;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateStatusCommand"/> class.
        /// </summary>
        /// <param name="tokens">The request tokens.</param>
        /// <param name="text">The status text.</param>
        /// <param name="optionalProperties">The optional properties.</param>
        public UpdateStatusCommand(OAuthTokens tokens, string text, StatusUpdateOptions optionalProperties)
            : base(HTTPVerb.POST, "statuses/update.json", tokens, optionalProperties)
        {
            if (tokens == null)
            {
                throw new ArgumentNullException("tokens");
            }

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("text");
            }

            this.Text = text;
        }
Esempio n. 11
0
        public void UpdateAndDelete()
        {
            OAuthTokens tokens = Configuration.GetTokens();

            StatusUpdateOptions options = new StatusUpdateOptions();

            var newStatus = TwitterStatus.Update(tokens, "Performing Twitterizer testing ...", options);

            Assert.IsNotNull(newStatus.ResponseObject, newStatus.ErrorMessage);
            Assert.IsTrue(newStatus.ResponseObject.Id > 0);

            var deletedStatus = newStatus.ResponseObject.Delete(tokens);

            Assert.IsNotNull(deletedStatus.ResponseObject, deletedStatus.ErrorMessage);
            Assert.IsTrue(newStatus.ResponseObject.Id == deletedStatus.ResponseObject.Id);
        }
Esempio n. 12
0
        public bool tweetIt(string status)
        {
            try
            {
                var userOptions = new StatusUpdateOptions();
                userOptions.APIBaseAddress = "https://api.twitter.com/1.1/"; // <-- needed for API 1.1
                userOptions.UseSSL         = true;                           // <-- needed for API 1.1

                var result = TwitterStatus.Update(tokens, status, userOptions);
                MessageBox.Show("Status updated successfuly");
                return(true);
            }
            catch (TwitterizerException te)
            {
                MessageBox.Show(te.Message);
                return(false);
            }
        }
Esempio n. 13
0
        public string tweet(string message)
        {
            TwitterResponse <TwitterStatus> tweetResponse = null;
            StatusUpdateOptions             opt           = new StatusUpdateOptions();

            opt.APIBaseAddress = "http://api.twitter.com/1.1/";
            try
            {
                tweetResponse = TwitterStatus.Update(tokens, message, opt);
            }
            catch {}
            if (tweetResponse == null)
            {
                return("");
            }
            else
            {
                return(tweetResponse.Content);
            }
        }
        /// <summary>
        /// Initializes the command.
        /// </summary>
        public override void Init()
        {
            this.RequestParameters.Add("status", this.Text);

            StatusUpdateOptions options = this.OptionalProperties as StatusUpdateOptions;

            if (options != null)
            {
                NumberFormatInfo nfi = CultureInfo.InvariantCulture.NumberFormat;

                if (options.InReplyToStatusId > 0)
                {
                    this.RequestParameters.Add("in_reply_to_status_id", options.InReplyToStatusId.ToString("#"));
                }

                if (options.Latitude != 0)
                {
                    this.RequestParameters.Add("lat", options.Latitude.ToString(nfi));
                }

                if (options.Longitude != 0)
                {
                    this.RequestParameters.Add("long", options.Longitude.ToString(nfi));
                }

                if (!string.IsNullOrEmpty(options.PlaceId))
                {
                    this.RequestParameters.Add("place_id", options.PlaceId);
                }

                if (options.PlacePin)
                {
                    this.RequestParameters.Add("display_coordinates", "true");
                }

                if (options.WrapLinks)
                {
                    this.RequestParameters.Add("wrap_links", "true");
                }
            }
        }
Esempio n. 15
0
        // ### Twitter de Clave 6-8 Parte II
        public void GenerarTwitt_68_II(string strText)
        {
            OAuthTokens tokens        = new OAuthTokens();
            string      twitt_enviar3 = "";

            // ### TW Ok CBMS
            tokens.AccessToken       = "1258537242-wMFPksYBAxEI2Q09C0mKDBJ6h4JLALPZGARdpfI";
            tokens.AccessTokenSecret = "S8cqL39kbK33UKEPlMQn4446NEl6PYdevdZkNIYc";
            tokens.ConsumerKey       = "6ESBNpQiO3sAd3kPMMMbNA";
            tokens.ConsumerSecret    = "B8PUYhI2J5FtAfmVmZEs9NK7WP1Eak2Ph8rayKrvho";

            twitt_enviar3 = strText + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ") ";

            //### API 1.1
            StatusUpdateOptions options = new StatusUpdateOptions();

            options.InReplyToStatusId = 12345;
            options.APIBaseAddress    = "https://api.twitter.com/1.1/";
            options.UseSSL            = true;

            TwitterResponse <TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, twitt_enviar3, options);
        }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateStatusCommand"/> class.
        /// </summary>
        /// <param name="tokens">The request tokens.</param>
        /// <param name="text">The status text.</param>
        /// <param name="fileData">The file to upload, as a byte array.</param>
        /// <param name="optionalProperties">The optional properties.</param>
        public UpdateWithMediaCommand(OAuthTokens tokens, string text, byte[] fileData, StatusUpdateOptions optionalProperties)
            : base(HTTPVerb.POST, "Set below", tokens, optionalProperties)
        {
            if (tokens == null)
            {
                throw new ArgumentNullException("tokens");
            }

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("text");
            }

            if (fileData == null || fileData.Length == 0)
            {
                throw new ArgumentException("file");
            }

            this.OptionalProperties.APIBaseAddress = "https://upload.twitter.com/1/";
            this.SetCommandUri("statuses/update_with_media.json");

            this.Text      = text;
            this.File      = fileData;
            this.Multipart = true;
        }
Esempio n. 17
0
        public ActionResult <Result <bool> > Post(int userId, int projectId, [FromBody] StatusUpdateOptions update)
        {
            var result = dashboardService_.StatusUpdate(userId, projectId, update.Text);

            return(result);
        }
Esempio n. 18
0
        public void TwittLinea1(int idExpediente, string invokeTwitter, string carrosDespachados)
        {
            e_expedientes exp          = new e_expedientes();
            OAuthTokens   tokens       = new OAuthTokens();
            string        twitt_enviar = "";

            // ### TW Ok CBMS
            tokens.AccessToken       = "1258537242-wMFPksYBAxEI2Q09C0mKDBJ6h4JLALPZGARdpfI";
            tokens.AccessTokenSecret = "S8cqL39kbK33UKEPlMQn4446NEl6PYdevdZkNIYc";
            tokens.ConsumerKey       = "6ESBNpQiO3sAd3kPMMMbNA";
            tokens.ConsumerSecret    = "B8PUYhI2J5FtAfmVmZEs9NK7WP1Eak2Ph8rayKrvho";


            foreach (DataRow rDatos in exp.GetDatosTwitter(idExpediente).Tables[0].Rows)
            {
                if (invokeTwitter == "FT1")
                {
                    twitt_enviar = "" + rDatos["clave"].ToString() + " " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT2")
                {
                    int intPrincipal = Convert.ToInt32(rDatos["codigo_principal"].ToString());
                    if (intPrincipal > 49)
                    {
                        twitt_enviar = "SALE " + carrosDespachados + " A INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                    }
                    else
                    {
                        twitt_enviar = "SALE " + carrosDespachados + " A " + rDatos["clave"].ToString() + " " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                    }
                }

                //### Incendios Estructural
                if (invokeTwitter == "FT3")
                {
                    twitt_enviar = "1er. BATALLON DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ") " + rDatos["material_despachado"].ToString() + " ";
                }

                if (invokeTwitter == "FT4")
                {
                    twitt_enviar = "2do. BATALLON DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT5")
                {
                    twitt_enviar = "3er. BATALLON DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT6")
                {
                    twitt_enviar = "4to. BATALLON DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT7")
                {
                    twitt_enviar = "5ta ALARMA DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT8")
                {
                    twitt_enviar = "6ta ALARMA DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT9")
                {
                    twitt_enviar = "7ma ALARMA DE INCENDIO " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                //### Incendios Forestal
                if (invokeTwitter == "FT3F")
                {
                    twitt_enviar = "INCENDIO FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ") " + rDatos["material_despachado"].ToString() + " ";
                }

                if (invokeTwitter == "FT4F")
                {
                    twitt_enviar = "2da ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT5F")
                {
                    twitt_enviar = "3ra ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT6F")
                {
                    twitt_enviar = "4ta ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT7F")
                {
                    twitt_enviar = "5ta ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT8F")
                {
                    twitt_enviar = "6ta ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                if (invokeTwitter == "FT9F")
                {
                    twitt_enviar = "7ma ALARMA FORESTAL " + rDatos["seis2"].ToString() + " / " + rDatos["cero5"].ToString() + " " + carrosDespachados + " (" + System.DateTime.Now.Hour.ToString() + ":" + System.DateTime.Now.Minute.ToString() + ":" + System.DateTime.Now.Second.ToString() + ")";
                }

                //### API 1.1
                StatusUpdateOptions options = new StatusUpdateOptions();
                options.InReplyToStatusId = 12345;
                options.APIBaseAddress    = "https://api.twitter.com/1.1/";
                options.UseSSL            = true;

                TwitterResponse <TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, twitt_enviar, options);

                if (tweetResponse.Result == RequestResult.Success)
                {
                    //SetLog("Twitteo generador con fecha " + System.DateTime.Now.ToString() + ", OK");
                    //### int intVal = EscribeLogTwitter(tweetResponse.Result.ToString());
                }
                else
                {
                    //SetLog("Con fecha " + System.DateTime.Now.ToString() + " el twitteo no se genero, el motivo: [" + tweetResponse.Result + "], NOOK");
                    //### int intVal = EscribeLogTwitter(tweetResponse.Result.ToString());
                }
            }
        }