Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7075037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:07:46+00:00 2026-05-28T06:07:46+00:00

to post updates to twitter i am using the following code. OAuthTokens tokens =

  • 0

to post updates to twitter i am using the following code.

OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = // My access token //;
tokens.AccessTokenSecret = // My access token secret //;
tokens.ConsumerKey = // My consumer key //;
tokens.ConsumerSecret = // My consumer secret//;
TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, "Hello, #Twitterizer");

Can any one help me with code to post status updates to twitter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:07:46+00:00Added an answer on May 28, 2026 at 6:07 am

    And you also need to register yours app as read/write (default is readonly) ,

    Or you would always receive the 401 error code.

    Good luck.

    UPDATE:

    Ok , This is my code.

    First is the Utility class , I think you could found a lot of such method in the internet.

    class Auth {
            const string REQUEST_TOKEN_URL = "https://twitter.com/oauth/request_token";
            const string ACCESS_TOKEN_URL = "https://twitter.com/oauth/access_token";
            const string AUTHORIZE_URL = "https://twitter.com/oauth/authorize";
    
            private Random random = new Random();
    
            public string ConsumerKey { get; private set; }
            public string ConsumerSecret { get; private set; }
            public string RequestToken { get; private set; }
            public string RequestTokenSecret { get; private set; }
            public string AccessToken { get; private set; }
            public string AccessTokenSecret { get; private set; }
            public string UserId { get; private set; }
            public string ScreenName { get; private set; }
    
            public Auth(string consumerKey, string consumerSecret) {
                ServicePointManager.Expect100Continue = false;
                ConsumerKey = consumerKey;
                ConsumerSecret = consumerSecret;
            }
    
            public Auth(string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret, string userId, string screenName) {
                ServicePointManager.Expect100Continue = false;
                ConsumerKey = consumerKey;
                ConsumerSecret = consumerSecret;
                AccessToken = accessToken;
                AccessTokenSecret = accessTokenSecret;
                UserId = userId;
                ScreenName = screenName;
            }
    
            public void GetRequestToken() {
                SortedDictionary<string, string> parameters = GenerateParameters("");
                string signature = GenerateSignature("", "GET", REQUEST_TOKEN_URL, parameters);
                parameters.Add("oauth_signature", UrlEncode(signature));
                string response = HttpGet(REQUEST_TOKEN_URL, parameters);
                Dictionary<string, string> dic = ParseResponse(response);
                RequestToken = dic["oauth_token"];
                RequestTokenSecret = dic["oauth_token_secret"];
            }
    
            public string GetAuthorizeUrl() {
                return AUTHORIZE_URL + "?oauth_token=" + RequestToken;
            }
    
            public void GetAccessToken(string pin) {
                SortedDictionary<string, string> parameters = GenerateParameters(RequestToken);
                parameters.Add("oauth_verifier", pin);
                string signature = GenerateSignature(RequestTokenSecret, "GET", ACCESS_TOKEN_URL, parameters);
                parameters.Add("oauth_signature", UrlEncode(signature));
                string response = HttpGet(ACCESS_TOKEN_URL, parameters);
                Dictionary<string, string> dic = ParseResponse(response);
                AccessToken = dic["oauth_token"];
                AccessTokenSecret = dic["oauth_token_secret"];
                UserId = dic["user_id"];
                ScreenName = dic["screen_name"];
            }
    
            public string Get(string url, IDictionary<string, string> parameters) {
                SortedDictionary<string, string> parameters2 = GenerateParameters(AccessToken);
                foreach (var p in parameters)
                    parameters2.Add(p.Key, p.Value);
                string signature = GenerateSignature(AccessTokenSecret, "GET", url, parameters2);
                parameters2.Add("oauth_signature", UrlEncode(signature));
                return HttpGet(url, parameters2);
            }
    
            public string Post(string url, IDictionary<string, string> parameters) {
                SortedDictionary<string, string> parameters2 = GenerateParameters(AccessToken);
                foreach (var p in parameters)
                    parameters2.Add(p.Key, p.Value);
                string signature = GenerateSignature(AccessTokenSecret, "POST", url, parameters2);
                parameters2.Add("oauth_signature", UrlEncode(signature));
                return HttpPost(url, parameters2);
            }
    
            private string HttpGet(string url, IDictionary<string, string> parameters) {
                WebRequest req = WebRequest.Create(url + '?' + JoinParameters(parameters));
                WebResponse res = req.GetResponse();
                Stream stream = res.GetResponseStream();
                StreamReader reader = new StreamReader(stream);
                string result = reader.ReadToEnd();
                reader.Close();
                stream.Close();
                return result;
            }
    
            string HttpPost(string url, IDictionary<string, string> parameters) {
                byte[] data = Encoding.ASCII.GetBytes(JoinParameters(parameters));
                WebRequest req = WebRequest.Create(url);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = data.Length;
                Stream reqStream = req.GetRequestStream();
                reqStream.Write(data, 0, data.Length);
                reqStream.Close();
                WebResponse res = req.GetResponse();
                Stream resStream = res.GetResponseStream();
                StreamReader reader = new StreamReader(resStream, Encoding.UTF8);
                string result = reader.ReadToEnd();
                reader.Close();
                resStream.Close();
                return result;
    
            }
    
            private Dictionary<string, string> ParseResponse(string response) {
                Dictionary<string, string> result = new Dictionary<string, string>();
                foreach (string s in response.Split('&')) {
                    int index = s.IndexOf('=');
                    if (index == -1)
                        result.Add(s, "");
                    else
                        result.Add(s.Substring(0, index), s.Substring(index + 1));
                }
                return result;
            }
    
            private string JoinParameters(IDictionary<string, string> parameters) {
                StringBuilder result = new StringBuilder();
                bool first = true;
                foreach (var parameter in parameters) {
                    if (first)
                        first = false;
                    else
                        result.Append('&');
                    result.Append(parameter.Key);
                    result.Append('=');
                    result.Append(parameter.Value);
                }
                return result.ToString();
            }
    
            private string GenerateSignature(string tokenSecret, string httpMethod, string url, SortedDictionary<string, string> parameters) {
                string signatureBase = GenerateSignatureBase(httpMethod, url, parameters);
                HMACSHA1 hmacsha1 = new HMACSHA1();
                hmacsha1.Key = Encoding.ASCII.GetBytes(UrlEncode(ConsumerSecret) + '&' + UrlEncode(tokenSecret));
                byte[] data = System.Text.Encoding.ASCII.GetBytes(signatureBase);
                byte[] hash = hmacsha1.ComputeHash(data);
                return Convert.ToBase64String(hash);
            }
    
            private string GenerateSignatureBase(string httpMethod, string url, SortedDictionary<string, string> parameters) {
                StringBuilder result = new StringBuilder();
                result.Append(httpMethod);
                result.Append('&');
                result.Append(UrlEncode(url));
                result.Append('&');
                result.Append(UrlEncode(JoinParameters(parameters)));
                return result.ToString();
            }
    
            private SortedDictionary<string, string> GenerateParameters(string token) {
                SortedDictionary<string, string> result = new SortedDictionary<string, string>();
                result.Add("oauth_consumer_key", ConsumerKey);
                result.Add("oauth_signature_method", "HMAC-SHA1");
                result.Add("oauth_timestamp", GenerateTimestamp());
                result.Add("oauth_nonce", GenerateNonce());
                result.Add("oauth_version", "1.0");
                if (!string.IsNullOrEmpty(token))
                    result.Add("oauth_token", token);
                return result;
            }
    
            public string UrlEncode(string value) {
                string unreserved = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
                StringBuilder result = new StringBuilder();
                byte[] data = Encoding.UTF8.GetBytes(value);
                foreach (byte b in data) {
                    if (b < 0x80 && unreserved.IndexOf((char)b) != -1)
                        result.Append((char)b);
                    else
                        result.Append('%' + String.Format("{0:X2}", (int)b));
                }
                return result.ToString();
            }
    
            private string GenerateNonce() {
                string letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                StringBuilder result = new StringBuilder(8);
                for (int i = 0; i < 8; ++i)
                    result.Append(letters[random.Next(letters.Length)]);
                return result.ToString();
            }
    
            private string GenerateTimestamp() {
                TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                return Convert.ToInt64(ts.TotalSeconds).ToString();
            }
        }
    

    This is console app , u can use it to get token by pincode

    class Program {
        const string CONSUMER_KEY = "yours CONSUMER_KEY";
        const string CONSUMER_SECRET = "yours CONSUMER_SECRET";
    
        static void Main(string[] args)
        {
            Auth auth = new Auth(CONSUMER_KEY, CONSUMER_SECRET);
    
    
            auth.GetRequestToken();
    
    
            Console.WriteLine("Get PinCode from here.");
            Console.WriteLine(auth.GetAuthorizeUrl());
            Console.Write("PinCode:");
            string pin = Console.ReadLine().Trim();
    
            auth.GetAccessToken(pin);
    
    
        Console.WriteLine("AccessToken: " + auth.AccessToken);
        Console.WriteLine("AccessTokenSecret: " + auth.AccessTokenSecret);
        Console.WriteLine("UserId: " + auth.UserId);
        Console.WriteLine("ScreenName: " + auth.ScreenName);
    
    
            Console.WriteLine("yours status.");
            string status = Console.ReadLine();
            parameters.Clear();
            parameters.Add("status", auth.UrlEncode(status));
            Console.WriteLine(auth.Post("http://twitter.com/statuses/update.xml", parameters));
        }
    }
    

    Then you can use yours token and token secret for next .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jquery ajax to post updates back to my server. I'm concerned about
Good morning, I am trying to pass a string to twitter, using the following
How can I post a message to twitter using only javascript (no serverside authentification).
Got the following error when using Ruby irb to test simple twitter status update
Using the code example on the Twitterizer website I am trying to post a
I'm using Twitter API to post tweets. At times this can take some time,
i am using a twitter script to post messages to the twitter wall from
I'm updating my user's Twitter status using the simple code below. My problem is
I'm trying to post to Twitter using the Twitter PHP SDK twitter-async my tweets
I was using Twitter Oath for twitter sharing, suddenly the same code is getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.