Send text from calgo to Twitter

Its pretty simple to send a tweet with C# using twitter API, you need to open a twitter account that you want to post from and get your authentication codes, it has been a while since i worked on the twitter API, but it is something like this:

// TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
TwitterCredentials.SetCredentials("2252688033-b20s6VyUbgMhhq60mgt8H5i1FlT2IkG", "Gb6q86w7WZR0BCFbPbeRMLLbxcMKowODjN8Ho4SdW", "1EDHuiqKRaor771Fu7SCy", "pguFU6zPYALGBtReR5vElfBLM78PLoSKbI23oGudh");

var tweet = Tweet.CreateTweet("this is your tweet");
var success = tweet.Publish();

you can also tweet with media images, so you can auto tweet every time you win a trade with a screen shot if your clever.

have fun.

~ Contact us for all your cBot & Indicator development ~
RE:

I found this (some errors recive) but send my text


        //function to post message to twitter (parameter string message)
        private void SendToTwitter(string message)
        {
            // Add this references first
            //using System.Net;
            //using System.IO;
            //using System.Security.Cryptography;
            //using System.Text;

            //The facebook json url to update the status
            string URL = "https://api.twitter.com/1.1/statuses/update.json";

            //set the access tokens (REQUIRED)
            string oauth_consumer_key = "";
            string oauth_consumer_secret = "";
            string oauth_token = "";
            string oauth_token_secret = "";

            // set the oauth version and signature method
            string oauth_version = "1.0";
            string oauth_signature_method = "HMAC-SHA1";

            // create unique request details
            string oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
            System.TimeSpan timeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc));
            string oauth_timestamp = Convert.ToInt64(timeSpan.TotalSeconds).ToString();

            // create oauth signature
            string baseFormat = "oauth_consumer_key={0}&oauth_nonce={1}&oauth_signature_method={2}" + "&oauth_timestamp={3}&oauth_token={4}&oauth_version={5}&status={6}";

            string baseString = string.Format(baseFormat, oauth_consumer_key, oauth_nonce, oauth_signature_method, oauth_timestamp, oauth_token, oauth_version, Uri.EscapeDataString(message));

            string oauth_signature = null;
            using (HMACSHA1 hasher = new HMACSHA1(ASCIIEncoding.ASCII.GetBytes(Uri.EscapeDataString(oauth_consumer_secret) + "&" + Uri.EscapeDataString(oauth_token_secret))))
            {
                oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes("POST&" + Uri.EscapeDataString(URL) + "&" + Uri.EscapeDataString(baseString))));
            }

            // create the request header
            string authorizationFormat = "OAuth oauth_consumer_key=\"{0}\", oauth_nonce=\"{1}\", " + "oauth_signature=\"{2}\", oauth_signature_method=\"{3}\", " + "oauth_timestamp=\"{4}\", oauth_token=\"{5}\", " + "oauth_version=\"{6}\"";

            string authorizationHeader = string.Format(authorizationFormat, Uri.EscapeDataString(oauth_consumer_key), Uri.EscapeDataString(oauth_nonce), Uri.EscapeDataString(oauth_signature), Uri.EscapeDataString(oauth_signature_method), Uri.EscapeDataString(oauth_timestamp), Uri.EscapeDataString(oauth_token), Uri.EscapeDataString(oauth_version));

            HttpWebRequest objHttpWebRequest = (HttpWebRequest)WebRequest.Create(URL);
            objHttpWebRequest.Headers.Add("Authorization", authorizationHeader);
            objHttpWebRequest.Method = "POST";
            objHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            using (Stream objStream = objHttpWebRequest.GetRequestStream())
            {
                byte[] content = ASCIIEncoding.ASCII.GetBytes("status=" + Uri.EscapeDataString(message));
                objStream.Write(content, 0, content.Length);
            }

            var responseResult = "";
            try
            {
                //success posting
                WebResponse objWebResponse = objHttpWebRequest.GetResponse();
                StreamReader objStreamReader = new StreamReader(objWebResponse.GetResponseStream());
                responseResult = objStreamReader.ReadToEnd().ToString();
                Print(responseResult);
            } catch (Exception ex)
            {
                //throw exception error
                responseResult = "Twitter Post Error: " + ex.Message.ToString() + ", authHeader: " + authorizationHeader;
                Print(responseResult);
            }
        }

Why?

I was using TweetInvi wrapper

https://tweetinvi.codeplex.com/

add the Nuget pachage to VS

https://www.nuget.org/packages/TweetinviAPI/

you will get the references I showed you above in your solution then simply write 3 meaningfully clear lines of code to send a tweet.

TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
 
var tweet = Tweet.CreateTweet("this is your tweet");
var success = tweet.Publish();

good luck.

~ Contact us for all your cBot & Indicator development ~
RE:

Paul_Hayes said:

I was using TweetInvi wrapper

https://tweetinvi.codeplex.com/

add the Nuget pachage to VS

https://www.nuget.org/packages/TweetinviAPI/

you will get the references I showed you above in your solution then simply write 3 meaningfully clear lines of code to send a tweet.

TwitterCredentials.SetCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
 
var tweet = Tweet.CreateTweet("this is your tweet");
var success = tweet.Publish();

good luck.

Thanks,

but if i copy my cbot to another pc where i have not instaled TweetinviApi  it will work or I need add TweetAPI (I prefer versions whitout external api i dont know who write it and how)?