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

  • Home
  • SEARCH
  • 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 7186005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:32:25+00:00 2026-05-28T18:32:25+00:00

So I am very new to C#, I started learning it a few days

  • 0

So I am very new to C#, I started learning it a few days ago and I would like to know how you can tweet with C#. I have searched google a lot, looked at some YouTube videos, but they are all old. I found Twitterizer.net, which has this code:

OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = "XXX";
tokens.AccessTokenSecret = "XXX";
tokens.ConsumerKey = "XXX";
tokens.ConsumerSecret = "XXX";

TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(tokens, "Hello,         #Twitterizer");
if (tweetResponse.Result == RequestResult.Success)
{
    messagebox.Show("Message Tweeted!");
}
else
{
   messageBox.Show("cannot tweet");
}

I put this code in a button, ‘button1’, but it doesn’t seem to work it pops up a messagebox saying cannot tweet. I have no idea why this is happening. I put this at the top using twitterizer;. I also got my consumer key, consumersecret, token and tokensecret. So I don’t know what is the problem, any help would be greatly appreciated. Thank You!

  • 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-28T18:32:26+00:00Added an answer on May 28, 2026 at 6:32 pm

    You should use the Twitter Callback. Set that up in the Developer section of Twitter.

    Try the following

    using System;
    using System.Diagnostics;
    using TweetSharp;
    using Hammock.Authentication.OAuth;
    
    public static string Token = "XXX"
    public static string TokenSecret = "XXX"
    public static string ConsumerKey = "XXX"
    public static string ConsumerSecret = "XXX"
    public static string Callback = "XXX"
    
    private static TwitterClientInfo TwitterClientInfo = new TwitterClientInfo()
    {
        ConsumerKey = ConsumerKey,
        ConsumerSecret = ConsumerSecret,
    };
    
    private static TwitterService TwitterService = new TwitterService(TwitterClientInfo);
    
    public static bool SetUpTwitter()
    {
        var OAuthCredentials = new OAuthCredentials
        {
            Type = OAuthType.RequestToken,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            ConsumerKey = ConsumerKey,
            ConsumerSecret = ConsumerSecret,
            CallbackUrl = "",
        };
    
        OAuthRequestToken requestToken = TwitterService.GetRequestToken(Callback);
        Uri authUrl = TwitterService.GetAuthorizationUri(requestToken, Callback);
    
        Process.Start(authUrl.AbsoluteUri);
    
        DateTime currentTime = DateTime.Now;
        DateTime endTime = currentTime.AddSeconds(30);
        while (currentTime < endTime)
        {
            currentTime = DateTime.Now;
        }
    
        OAuthAccessToken accessToken = TwitterService.GetAccessToken(requestToken);
        return SendMessage(accessToken.Token, accessToken.TokenSecret, "Send Sample Tweet");
    }
    
    public static bool SendMessage(string token, string tokenSecret, string message)
    {
        Token = token;
        TokenSecret = tokenSecret;
    
        if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(tokenSecret))
            return SetUpTwitter();
    
        try
        {
            TwitterService.AuthenticateWith(token, tokenSecret);
            TwitterService.SendTweet(message);
    
            return true;
        }
    
        catch
        {
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’ve started learning Erlang a few days ago and it’s definitely a very interesting
I am very new to Flex (started learning a couple of days back), I
Since I've started programming in Rails 5 days ago. I'm learning very many aspects
Guys i am very new to jQuery. I have started using the auto complete
I am new to NHibernate and have just started right now. I have very
I just started learning Objective-C and OOP ... so I have very stupid question
I have just started working with a new company in a very small IT
I am very new to parsing XML, and I started learning about linq which
I am very new to WPF. And just started learning threading. Here is my
i am very new to ios development, rather i have just started work on

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.